In this post we are trying to move the sql profiles that we created in one environment to another. as we now we cretae these sql profiles to make the sql performance better. And once this is tested we want to use the same profile to all env....
to do this we need to do the below steps...
1. Creating a staging table to store the SQL Profiles
exec DBMS_SQLTUNE.CREATE_STGTAB_SQLPROF (table_name=>'SQL_PROFILES_TT',schema_name=>'schema_name');
2) Packing the SQL Profiles to the staging table
SELECT name FROM dba_sql_profiles; ---once you have created the profile with OEM/db.
SYS_SQLPROF_013c88540c760000'
EXEC DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (staging_table_name => 'SQL_PROFILES_TT',profile_name=>'SYS_SQLPROF_013c88540c760000');
3. Export table using “expdp” tool from the source database
4. Export table using “impdp” tool to the destination database
5) SQL> conn / as sysdba
Connected.
SQL> grant administer sql management object to schema_name;
Grant succeeded.
Note: you will get below error if you dont have not given the "administer sql management object " privilege...
SQL> conn schema_name/passd
Connected.
SQL> EXEC DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(REPLACE => TRUE,staging_table_name=> 'SQL_PROFILES_TT');
BEGIN DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(REPLACE => TRUE,staging_table_name=> 'SQL_PROFILES_TT'); END;
*
ERROR at line 1:
ORA-38171: Insufficient privileges for SQL management object operation
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_SMB", line 83
ORA-06512: at "SYS.DBMS_SQLTUNE", line 7657
ORA-06512: at "SYS.DBMS_SQLTUNE", line 6349
ORA-06512: at line 1
SQL> conn schema_name/passd
Connected.
SQL> show user;
USER is "schema_name"
SQL> EXEC DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(REPLACE => TRUE,staging_table_name=> 'SQL_PROFILES_TT');
PL/SQL procedure successfully completed.
SQL> conn / as sysdba
Connected.
SQL> select name from dba_sql_profiles;
NAME
------------------------------
SYS_SQLPROF_010c760000
Hope this helps....