Thursday, April 12, 2007

How to Use DBMS_STATS to Move Statistics to a Different Database

Create stat table

SQL> exec dbms_stats.create_stat_table('SCOTT','STATS');

Export statistics into stat table

SQL> exec dbms_stats.export_table_stats('SCOTT',-
'EMP',NULL,'STATS',NULL,TRUE);

Export stat table from source database

%exp scott/tiger tables=STATS file=expstat.dmp

Import stat table into target database

%imp scott/tiger file=expstat.dmp full=y log=implog.txt

Import statistics into table

SQL> exec dbms_stats.import_table_stats('SCOTT',-
'EMP',-NULL,'STATS',NULL,TRUE);

SQL >