> Home > Scripts > Oracle >

Generate a script to analyze tables and indexes

This script should be run from SQL*plus prompt. This can also be placed in a file and ran from the SQL*plus prompt

 

SET spool analyze_database.sql

SET head off

SET pagesize 0

SELECT 'ANALYZE TABLE ' ||TABLE_NAME ||' COMPUTE STATISTICS ;' FROM USER_TABLES

/

SELECT 'ANALYZE INDEX ' ||INDEX_NAME ||' COMPUTE STATISTICS ;' FROM USER_INDEXES

/

 

SET spool off