1.
tj_nohup.sql
sqlplus "/as sysdba" <@tj_index_rebuild.sql
exit;
eof
2.tj_index_rebuild.sql
spool index_first_total.txt
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
select sum(bytes)/1024/1024/1024 INDEX_TOTAL_SUM_G from dba_segments where segment_type='INDEX';
spool off
set head off
set feedback off
spool index_rebuild.sql
SELECT 'ALTER INDEX ' ||OWNER||'.'||SEGMENT_NAME ||' REBUILD ONLINE;' FROM DBA_SEGMENTS WHERE segment_type='INDEX' ORDER BY BYTES ;
spool off
set head off
set feedback off
spool p_index_rebuild.sql
SELECT 'ALTER INDEX ' ||OWNER||'.'||SEGMENT_NAME ||' REBUILD PARTITION '||PARTITION_NAME ||' tablespace ultranms_index;' FROM DBA_SEGMENTS WHERE segment_type='INDEX PARTITION' and owner='ULTRANMS' ORDER BY BYTES ;
spool off
spool index_rebuild.log
set header on
set feedback on
set timing on
@index_rebuild.sql
@p_index_rebuild.txt
spool off
spool index_second_total.txt
select sum(bytes)/1024/1024/1024 INDEX_TOTAL_SUM_G from dba_segments where segment_type='INDEX';
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
spool off
3.nohup sh tj_nohup.sql &
阅读(2065) | 评论(0) | 转发(0) |