重建ORACLE資料庫索引

2021-04-13 07:48:00 字數 561 閱讀 8480

declare

str varchar2(400);

begin

-- 重建oracle索引

for tmp_idx in (select tablespace_name, owner, table_name, index_name

from all_indexes

where owner = 'hnacms'

and temporary = 'n'    

--and table_name = 'k_task'             

--and tablespace_name <> 'hnacms_indx'

order by tablespace_name, table_name) loop

str := 'alter index ' || tmp_idx.owner || '.' || tmp_idx.index_name ||

' rebuild tablespace hnacms_indx';

execute immediate str;

end loop;

end;

Oracle如何批量重建資料庫索引

查詢資料庫索引的方法 select from user indexes 由此我們可以查到該資料庫下面的所有索引資訊,然後批量生成sql重建語句。sql的索引重建語句如下 alter index pk tf t spv testindex rebuild 批量生成的方法是首先將查詢的資料庫index ...

重建資料庫表所有索引

重建資料庫表所有索引 2006 06 12 先選擇要修復的資料庫 declare name varchar 100 所有使用者表游標 declare authors cursor cursor for select name from sysobjects where xtype u order b...

重建資料庫表所有索引

重建資料庫表所有索引 2006 06 12 先選擇要修復的資料庫 declare name nvarchar 255 所有使用者表游標 declare authors cursor cursor for select name from sysobjects where xtype u order ...