通过以下字段查询索引名称,然后重建
SQL> desc user_indexes
Name Type Nullable Default Comments
----------------------- -------------- -------- ------- ---------------------------------------------------------------------------------
INDEX_NAME VARCHAR2(30) Name of the index
INDEX_TYPE VARCHAR2(27) Y
TABLE_OWNER VARCHAR2(30) Owner of the indexed object
TABLE_NAME VARCHAR2(30) Name of the indexed object
TABLE_TYPE VARCHAR2(11) Y Type of the indexed object
create or replace procedure p_rebuild_index( user_name in varchar2 ) as v_sql varchar(200); begin for idx in (select index_name from user_indexes where table_owner=upper(user_name) and status='VALID' and temporary = 'N') loop begin v_sql := 'alter index ' || idx.index_name || ' rebuild '; dbms_output.put_line(idx.index_name); dbms_output.put_line(v_sql); execute immediate v_sql; exception when others then dbms_output.put_line(sqlerrm); end; end loop; end; /