If you need to generate SQL Profiles and then move to another instance below are the procedures. Just keep in mind that in the example below i generated the SQL Profiles in advance (5) then restored and imported to the same instance.
1- Already had the table so I dropped
SYS@ELSIPOC1 SQL> drop table alex.sql_profiles;
Table dropped.
2- Create the staging table
SYS@ELSIPOC1 SQL> SYS@ELSIPOC1 SQL> BEGIN
2 DBMS_SQLTUNE.CREATE_STGTAB_SQLPROF (
3 table_name => ‘SQL_PROFILES’,
4 schema_name=>’ALEX’);
5 END;
6 /
PL/SQL procedure successfully completed.
3- Packed all the existing SQL profiles in the staging table
SYS@ELSIPOC1 SQL>
SYS@ELSIPOC1 SQL> BEGIN
2 DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (
3 profile_category => ‘%’,
4 staging_table_name => ‘SQL_PROFILES’,
5 staging_schema_owner=>’ALEX’);
6 END;
7 /
PL/SQL procedure successfully completed.
4- Count the staging table
SYS@ELSIPOC1 SQL> select count(*) from alex.sql_profiles;
COUNT(*)
———-
5
SYS@ELSIPOC1 SQL>exit
5- Export the staging table
[spocoradb1.aeso.ca]/dbadmin/workspace2/RAT/capture/CDMS>expdp system/abc123 dumpfile=expdp_sql_profiles.dmp TABLES=ALEX.SQL_PROFILES DIRECTORY=CDMS_REPLAY
Export: Release 11.2.0.1.0 – Production on Tue Jun 8 11:14:04 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
Starting “SYSTEM”.”SYS_EXPORT_TABLE_01″: system/******** dumpfile=expdp_sql_profiles.dmp TABLES=ALEX.SQL_PROFILES DIRECTORY=CDMS_REPLAY
Estimate in progress using BLOCKS method…
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 384 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported “ALEX”.”SQL_PROFILES” 98.50 KB 5 rows
Master table “SYSTEM”.”SYS_EXPORT_TABLE_01″ successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TABLE_01 is:
/dbadmin/workspace2/RAT/capture/CDMS/expdp_sql_profiles.dmp
Job “SYSTEM”.”SYS_EXPORT_TABLE_01″ successfully completed at 11:14:53
###
6- Restore the database to a backup taken before All 5 SQL profiles were generated###
7- Truncate all the records from staging table
SYS@ELSIPOC1 SQL> truncate table alex.sql_profiles;
Table truncated.
SYS@ELSIPOC1 SQL> exit
8- import the staging table
[spocoradb1.aeso.ca]/dbadmin/workspace2/RAT/capture/CDMS>impdp system/abc123 dumpfile=expdp_sql_profiles.dmp TABLES=ALEX.SQL_PROFILES DIRECTORY=CDMS_REPLAY TABLE_EXISTS_ACTION=REPLACE
Import: Release 11.2.0.1.0 – Production on Tue Jun 8 11:22:49 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
Master table “SYSTEM”.”SYS_IMPORT_TABLE_01″ successfully loaded/unloaded
Starting “SYSTEM”.”SYS_IMPORT_TABLE_01″: system/******** dumpfile=expdp_sql_profiles.dmp TABLES=ALEX.SQL_PROFILES DIRECTORY=CDMS_REPLAY TABLE_EXISTS_ACTION=REPLACE
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported “ALEX”.”SQL_PROFILES” 98.50 KB 5 rows
Job “SYSTEM”.”SYS_IMPORT_TABLE_01″ successfully completed at 11:22:54
[spocoradb1.aeso.ca]/dbadmin/workspace2/RAT/capture/CDMS>
9- Drop the 2 existing SQL profiles that were in the instance when backup was taken.
SYS@ELSIPOC1 SQL> BEGIN
dbms_sqltune.drop_sql_profile(‘SYS_SQLPROF_0228d51a0db60000′, TRUE);
END;
/ 2 3 4
PL/SQL procedure successfully completed.
SYS@ELSIPOC1 SQL> BEGIN
dbms_sqltune.drop_sql_profile(‘SYS_SQLPROF_0128d2628b7e0000′, TRUE);
END;
/ 2 3 4
PL/SQL procedure successfully completed.
10- Unpack the SQL profiles from the staging table
SYS@ELSIPOC1 SQL> BEGIN
DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(
staging_table_name => ‘SQL_PROFILES’,
staging_schema_owner=>’ALEX’,
replace=>FALSE);
END;
/ 2 3 4 5 6 7
PL/SQL procedure successfully completed.
SYS@ELSIPOC1 SQL>
And you should be done…….