Migrating optimizer statistics from Prod to Test database's

On Production Server...

Create stats table using...

SQL> EXEC DBMS_STATS.CREATE_STAT_TABLE(ownname=> 'PROD_SCHEMA', stattab=>'STATS_08JAN2016');

Export statistics using..

SQL>  EXEC DBMS_STATS.EXPORT_SCHEMA_STATS(ownname => 'PROD_SCHEMA',stattab => 'STATS_08JAN2016');

Export the stats table using...

 expdp dumpfile=DPUMP_DIR1:Prod_statistics.dmp logfile=DPUMP_DIR1:Prod_statistics.log tables=PROD_SCHEMA.STATS_08JAN2016


scp the dump file to the destination server...

Now on the destionation server...

Import the table into the destination database using...

impdp dumpfile=DPUMP_DIR1:Prod_statistics.dmp  logfile=DPUMP_DIR1:Prod_stats_into_Test.log remap_schema=PROD_SCHEMA:TEST_SCHEMA full=y table_exists_action=truncate

Update the statistics table to reflect the target schema...this step is required if the target schema is different from source(prod) schema

UPDATE TEST_SCHEMA.STATS_08JAN2016 SET C5='TEST_SCHEMA' WHERE C5='PROD_SCHEMA';

Import the schema level statistics using...


EXEC DBMS_STATS.IMPORT_SCHEMA_STATS(ownname => 'TEST_SCHEMA', stattab => 'STATS_08JAN2016');

0 comments:

Post a Comment