oracle 批量重建索引create or replace procedure p_rebuild_all_index
oracle 批量重建索引   (tablespace_name 
in varchar2)
oracle 批量重建索引
as
oracle 批量重建索引   sqlt 
varchar(200);
oracle 批量重建索引
begin
oracle 批量重建索引
oracle 批量重建索引    
for idx in (select index_name, tablespace_name, status from user_indexes where tablespace_name=tablespace_name and status='VALID' and temporary = 'N') loop
oracle 批量重建索引    
begin
oracle 批量重建索引           sqlt :
= 'alter index ' || idx.index_name || ' rebuild ';
oracle 批量重建索引           dbms_output.put_line(idx.index_name);
oracle 批量重建索引           dbms_output.put_line(sqlt);
oracle 批量重建索引           
EXECUTE IMMEDIATE sqlt;
oracle 批量重建索引           
--错误后循环继续执行。
oracle 批量重建索引
           EXCEPTION
oracle 批量重建索引           
WHEN OTHERS THEN
oracle 批量重建索引                dbms_output.put_line(SQLERRM);
oracle 批量重建索引     
end;              
oracle 批量重建索引     
end loop;
oracle 批量重建索引
end;
oracle 存储过程批量重建索引。
测试方法
declare
    --表空间名称
  tablespace_name varchar2(100);
begin
  tablespace_name:='dddd';
  p_rebuild_all_index(tablespace_name);
end;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2022-12-23
  • 2021-11-14
  • 2021-09-02
  • 2022-12-23
相关资源
相似解决方案