首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

目录重建

2013-03-04 
索引重建通过以下字段查询索引名称,然后重建?SQL desc user_indexesName ? ? ? ? ? ? ? ? ? ?Type ? ? ?

索引重建

通过以下字段查询索引名称,然后重建

?

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') loopbegin           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;/

?

?

热点排行