A SQL profile fixed in a test environment often needs to follow the code to production. Oracle provides a staging-table mechanism in DBMS_SQLTUNE for exactly that.
1. List the profiles to retrieve the profile name
SELECT * FROM DBA_SQL_PROFILES;
2. Create the staging table
BEGIN
DBMS_SQLTUNE.CREATE_STGTAB_SQLPROF (
table_name => 'TMP_SQL_PROFILES'
, schema_name => 'SYSTEM'
);
END;
3. Pack the profile into the staging table
Use the profile NAME found in step 1.
BEGIN
DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (
profile_name => 'SYS_SQLPROF_02701ab7b57c0000'
, staging_table_name => 'TMP_SQL_PROFILES'
, staging_schema_owner => 'SYSTEM'
);
END;
4. Move the staging table to the target database
Any table transfer works; with Data Pump:
# On the source server
expdp system tables=SYSTEM.TMP_SQL_PROFILES directory=DATA_PUMP_DIR dumpfile=sql_profiles.dmp
# Copy the dump file to the target server, then
impdp system tables=SYSTEM.TMP_SQL_PROFILES directory=DATA_PUMP_DIR dumpfile=sql_profiles.dmp
5. Unpack the profile in the target database
BEGIN
DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(
replace => true
, staging_table_name => 'TMP_SQL_PROFILES'
, staging_schema_owner => 'SYSTEM'
);
END;
The profile is active as soon as it is unpacked. Check it in DBA_SQL_PROFILES on the target, then drop the staging table on both sides.