Saturday 30 May 2015

Oracle 10g, 11g: Export and Import schema statistics


Easy way to export and import schema statistics – in case the optimizer is behaving incorrectly and you want to re-import old statistics when the optimizer behaved properly.

SCHEMA NAME – POWERCARD

Create the table to store the statistics-
EXEC DBMS_STATS.CREATE_STAT_TABLE('POWERCARD', 'STATS_TABLE');

Export schema stats – will be stored in the 'STATS_TABLE'
EXEC DBMS_STATS.export_schema_stats('POWERCARD','STATS_TABLE',NULL,'POWERCARD');

If required import these statistics back to POWERCARD schema.
EXEC DBMS_STATS.import_schema_stats('POWERCARD','STATS_TABLE',NULL,'POWERCARD');

Finally drop the table created to backup the schema stats
EXEC DBMS_STATS.drop_stat_table('POWERCARD','STATS_TABLE');

No comments:

Post a Comment

Number of Visitors