Generate Script to Analyze on all DBA/SYS Partitioned Tables (Except AWR)

Generate Script to Analyze on all DBA/SYS Partitioned Tables (Except AWR)
$ sqlplus -s / as sysdba < analyze_all_DBA_par_tables.sql
set head off
set linesize 150
set pagesize 1000
select 'analyze table '||t.owner||'.'||t.table_name||' partition ('||p.partition_name||
') validate structure cascade into invalid_rows;'
from user_tab_partitions p, dba_tables t
where p.table_name = t.table_name
and t.owner IN ('SYS', 'SYSTEM', 'AUD_OWNER', 'DBSNMP', 'OUTLN')
and t.table_name NOT LIKE 'WR%'
and t.partitioned='YES'
order by t.owner, t.table_name;
exit
EOF

$ cat analyze_all_DBA_par_tables.sql

analyze table SYS.STREAMS$_APPLY_SPILL_MSGS_PART partition (P0) validate structure cascade into invalid_rows;

$ sqlplus / as sysdba;
SQL> spool analyze_all_DBA_par_tables.log
SQL> @analyze_all_DBA_par_tables.sql
SQL> spool off

$ cat analyze_all_DBA_par_tables.log | grep -i "Table analyzed" | wc | awk '{print $1}'

$ cat analyze_all_DBA_par_tables.log | grep -i ORA
$ cat analyze_all_DBA_par_tables.log | grep -i "analyze table"


any maintenance on database server should be handled in controlled manner i.e DBA shutdown database gracefully before any maintenance begins and start the database post maintenance , perform sanity check. Pls cascade this info locally.


请使用浏览器的分享功能分享到微信等