DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Saturday, July 14, 2018

Transfer sql profiles from one database to another



Summary

Here is a simple guide to transfer sql profiles from one database to another.

For better understanding assume that you want to transfer one sql profile from the 'source' database to the 'destination' database.

1. Connect to the source database as sysdba and grant the required privileges to the user which will own the staging table.
For this example the user is testuser.
$ sqlplus "/ as sysdba"
GRANT ADMINISTER SQL MANAGEMENT OBJECT TO testuser;
2. Connect as user testuser to the source db and create the staging table.
BEGIN
DBMS_SQLTUNE.CREATE_STGTAB_SQLPROF (table_name => 'SQL_PROFILES_STGTABLE');
END;
/
3. Check the existing sql profiles at the source db and copy the desired to the staging table
SELECT * FROM dba_sql_profiles ORDER BY created DESC;

BEGIN
DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (profile_name => 'SYS_SQLPROF_025c8ac7a1c50001', staging_table_name => 'SQL_PROFILES_STGTABLE');
END;
/

SELECT * FROM testuser.SQL_PROFILES_STGTABLE;
4. Copy the staging table SQL_PROFILES_STGTABLE from the source db to the destination db.
5. Grant again at the destination db the required privilege.
GRANT ADMINISTER SQL MANAGEMENT OBJECT TO testuser;
6. Add the sql profiles from the staging table to the destination db.
BEGIN
DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(REPLACE => TRUE, staging_table_name => 'SQL_PROFILES_STGTABLE');
END;
/

SELECT * FROM dba_sql_profiles ORDER BY created DESC;

No comments: