在ORACLE里按用户名重建索引的方法
2006-10-24 16:18
411 查看
---------------------------------------------------------------------------
SET ECHO OFF;
SET FEEDBACK OFF;
SET VERIFY OFF;
SET PAGESIZE 0;
SET TERMOUT ON;
SET HEADING OFF;
ACCEPT username CHAR PROMPT 'Enter the index username: ';
spool /oracle/rebuild_&username.sql;
SELECT
'REM +-----------------------------------------------+' || chr(10) ||
'REM | INDEX NAME : ' || owner || '.' || segment_name
|| lpad('|', 33 - (length(owner) + length(segment_name)) )
|| chr(10) ||
'REM | BYTES : ' || bytes
|| lpad ('|', 34-(length(bytes)) ) || chr(10) ||
'REM | EXTENTS : ' || extents
|| lpad ('|', 34-(length(extents)) ) || chr(10) ||
'REM +-----------------------------------------------+' || chr(10) ||
'ALTER INDEX ' || owner || '.' || segment_name || chr(10) ||
'REBUILD ' || chr(10) ||
'TABLESPACE ' || tablespace_name || chr(10) ||
'STORAGE ( ' || chr(10) ||
' INITIAL ' || initial_extent || chr(10) ||
' NEXT ' || next_extent || chr(10) ||
' MINEXTENTS ' || min_extents || chr(10) ||
' MAXEXTENTS ' || max_extents || chr(10) ||
' PCTINCREASE ' || pct_increase || chr(10) ||
');' || chr(10) || chr(10)
FROM dba_segments
WHERE segment_type = 'INDEX'
AND owner='&username'
ORDER BY owner, bytes DESC;
spool off;
-----------------------------------------------------------------------------
如果你用的是WINDOWS系统, 想改变输出文件的存放目录, 修改spool后面的路径成:
spool c:/oracle/rebuild_&username.sql;
如果你只想对大于max_bytes的索引重建索引, 可以修改上面的SQL语句:
在AND owner='&username' 后面加个限制条件 AND bytes> &max_bytes
如果你想修改索引的存储参数, 在重建索引rebuild_&username.sql里改也可以.
比如把pctincrease不等于零的值改成是零.
如果你想把index从一个TABLESPACE转移到另外一个TABLESPACE,也可以修改其中的tablespace_name
信息来源: http://www.cnoug.org/viewthread.php?tid=28211
SET ECHO OFF;
SET FEEDBACK OFF;
SET VERIFY OFF;
SET PAGESIZE 0;
SET TERMOUT ON;
SET HEADING OFF;
ACCEPT username CHAR PROMPT 'Enter the index username: ';
spool /oracle/rebuild_&username.sql;
SELECT
'REM +-----------------------------------------------+' || chr(10) ||
'REM | INDEX NAME : ' || owner || '.' || segment_name
|| lpad('|', 33 - (length(owner) + length(segment_name)) )
|| chr(10) ||
'REM | BYTES : ' || bytes
|| lpad ('|', 34-(length(bytes)) ) || chr(10) ||
'REM | EXTENTS : ' || extents
|| lpad ('|', 34-(length(extents)) ) || chr(10) ||
'REM +-----------------------------------------------+' || chr(10) ||
'ALTER INDEX ' || owner || '.' || segment_name || chr(10) ||
'REBUILD ' || chr(10) ||
'TABLESPACE ' || tablespace_name || chr(10) ||
'STORAGE ( ' || chr(10) ||
' INITIAL ' || initial_extent || chr(10) ||
' NEXT ' || next_extent || chr(10) ||
' MINEXTENTS ' || min_extents || chr(10) ||
' MAXEXTENTS ' || max_extents || chr(10) ||
' PCTINCREASE ' || pct_increase || chr(10) ||
');' || chr(10) || chr(10)
FROM dba_segments
WHERE segment_type = 'INDEX'
AND owner='&username'
ORDER BY owner, bytes DESC;
spool off;
-----------------------------------------------------------------------------
如果你用的是WINDOWS系统, 想改变输出文件的存放目录, 修改spool后面的路径成:
spool c:/oracle/rebuild_&username.sql;
如果你只想对大于max_bytes的索引重建索引, 可以修改上面的SQL语句:
在AND owner='&username' 后面加个限制条件 AND bytes> &max_bytes
如果你想修改索引的存储参数, 在重建索引rebuild_&username.sql里改也可以.
比如把pctincrease不等于零的值改成是零.
如果你想把index从一个TABLESPACE转移到另外一个TABLESPACE,也可以修改其中的tablespace_name
信息来源: http://www.cnoug.org/viewthread.php?tid=28211
相关文章推荐
- Oracle按用户名重建索引方法浅析
- ORACLE里按用户名重建索引的方法
- 在ORACLE里按用户名重建索引的方法
- 在ORACLE里按用户名重建索引的方法
- [转贴]在ORACLE里按用户名重建索引的方法
- 在ORACLE里按用户名重建索引的方法
- Oracle中加速索引创建或重建的方法
- Oracle中加速索引创建或重建的方法
- ORACLE按用户名重建索引
- 在Oracle数据库中按用户名重建索引的方法
- Oracle中加速索引创建或重建的方法
- oracle 索引什么时候重建和重建方法讨论
- 在Oracle数据库中按用户名重建索引的方法
- 在Oracle数据库中按用户名重建索引的方法-开发技术
- oracle 重建索引以及导出所有的索引脚本(可以解决还原数据库文件时先还原数据,在重新用脚本创建索引)
- Oracle表与索引的分析及索引重建
- Oracle 重建所有表的索引的存储过程 (重建索引)
- Oracle 11g Dos下 找回用户名和修改密码方法
- Oracle表与索引的分析及索引重建
- ORACLE 如何查看索引重建进度情况