移动索引的存储过程

(1)以smngb/smngdb登录数据库xmyj ,打开窗口创建以下存储过程脚本;

create or replace procedure tmp1

is

begin

  declare CURSOR cur IS  SELECT 'alter index '||index_name||' rebuild tablespace XMYJ' FROM user_indexes T where t.table_owner='SMNGDB' and t.tablespace_name='USERS' and index_name not like 'SYS_%';

  v_str varchar2(1000);

  c number;

  BEGIN

    OPEN cur;

    c := 0;

    LOOP

       FETCH cur INTO v_str;

       EXIT WHEN cur%NOTFOUND;

       execute immediate v_str;

       COMMIT;

       c := c + 1;

       dbms_output.put_line(v_str);

    END Loop;

    CLose Cur;

  end;

end tmp1;

(2)新打开一个窗口调用存储过程执行如下脚本:

call tmp1();

(3)           执行完成后,删除存储过程,执行如下脚本:

drop procedure  smngdb.tmp1

请使用浏览器的分享功能分享到微信等