Oracle 重建所有表的索引的存储过程 (重建索引)
2009-08-21 09:12
330 查看
create or replace procedure p_rebuild_all_index (tablespace_name in varchar2,--这里是表空间名,如果不改变表空间,可以传入null only_unusable in boolean) --是否仅对无效的索引操作 as sqlt varchar(200); begin --只取非临时索引 for idx in (select index_name, tablespace_name, status from user_indexes where temporary = 'N') loop --如果是如重建无效的索引,且当索引不是无效时,则跳过 if only_unusable = true and idx.status <> 'UNUSABLE' then goto continue; end if; if (tablespace_name is null) or idx.status = 'UNUSABLE' then --如果没有指定表空间,或索引无效,则在原表空间重建 sqlt := 'alter index ' || idx.index_name || ' rebuild '; elsif upper(tablespace_name) <> idx.tablespace_name then --如果指定的不同的表空间,则在指定表空间待建索引 sqlt := 'alter index ' || idx.index_name || ' rebuild tablespace ' || tablespace_name; else --如果表空间相同,则跳过 goto continue; end if; dbms_output.put_line(idx.index_name); EXECUTE IMMEDIATE sqlt; <<continue>> null; end loop; end; /* 功能:重建索引。 说明:如果表空间参数传入null,则在原表空间内重建索引,否则在目标表空间重建索引。 如果表空间相同,则跳过。 only_unusable表示是否只对无效的索引进行重建 作者:81, 2007年6月26日 */ |
相关文章推荐
- Oracle 重建所有表的索引的存储过程 (重建索引)
- Oracle 重建所有表的索引的存储过程 (重建索引)
- sqlserver重建所有索引的存储过程
- ORACLE小工具:存储过程清空所有表或使所有触发器失效
- Oracle 导出、导入某用户所有数据(包括表、视图、存储过程...)
- 重建所有索引(Oracle)
- Oracle 利用存储过程 删除用户下所有表
- SQL Server查询数据库所有存储过程、触发器、索引信息SQL分享
- Oracle问题小记五:服务启动-索引-子查询-分页存储过程
- 转发Oracle 导出、导入某用户所有数据(包括表、视图、存储过程...)
- 存储过程中动态重建指定表的索引
- SQL Server查询所有存储过程信息、触发器、索引
- 记录一则ORACLE MOVE操作后重建索引过程被强制中断导致的ORA-8104案例
- SQL Server查询数据库所有存储过程、触发器、索引信息SQL分享
- sql server 查询所有表的字段的详细信息的存储过程(在 SQL Server 2005 中查询表结构及索引 )
- 折腾Oracle问题小菜记[分页存储过程/查询所有表、视图、存储过程/查询表、视图、存储过程字段结构与参数](三)
- oracle删除当前用户所有表,视图,存储过程等
- 删除数据库的所有存储过程、主键、外键、索引等
- 在Oracle中重编译所有无效的存储过程
- 折腾Oracle问题小菜记[分页存储过程/查询所有表、视图、存储过程/查询表、视图、存储过程字段结构与参数](三)