Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Oracle Recommended Patches — Oracle Database ID 756671.1 Oracle
  • telnet listening Linux/Unix
  • Privilege to describe the table. Oracle
  • How to know Number of CPUs on Sun Box Linux/Unix
  • To see how much time or progress of long transaction Oracle
  • proc.sql Oracle
  • Monitor Long Running Job Oracle
  • find_string_in_database.sql Oracle
  • create database syntax Oracle
  • cif crons Linux/Unix
  • tar and untar a dolder with all its subfolder. Linux/Unix
  • useful dg links Oracle
  • More info about /proc folder and its relation with processes. Linux/Unix
  • avail.sh ( find filesystem spae usage) Linux/Unix
  • get_vmstat.ksh for Solaris Oracle

Transfer SQL Profiles from One database to other database.

Posted on 05-Sep-2024 By Admin No Comments on Transfer SQL Profiles from One database to other database.

In this guide, I’ll walk you through moving SQL profiles using a staging table. SQL profiles help databases optimize query execution plans.

Step#1 Create the Staging Table

First, create a staging table to hold SQL profiles that need to be transferred.

SQL> exec DBMS_SQLTUNE.CREATE_STGTAB_SQLPROF(table_name => 'SQL_STG_TAB', schema_name => 'SYS');

This will create a table SQL_STG_TAB that holds SQL profiles. Its structure matches the DBA_SQL_PROFILES table

Step#2 Find the Profile Name to Move

To pack a particular SQL profile, identify its name by querying the DBA_SQL_PROFILES table.

SQL> select name from DBA_SQL_PROFILES where SQL_TEXT like '%SELECT%EMPLOYEE%NAME%';
NAME
---------------------
SYS_SQLPROF_014b

Step#3 Pack the Custom Profile to Staging Table

To pack a specific profile into the staging table:

SQL> EXEC DBMS_SQLTUNE.PACK_STGTAB_SQLPROF(staging_table_name => 'SQL_STG_TAB', profile_name => 'SYS_SQLPROF_014b');

To pack all profiles under the DEFAULT category:

SQL> EXEC DBMS_SQLTUNE.PACK_STGTAB_SQLPROF(staging_table_name => 'SQL_STG_TAB');

Step#4 Export the Staging Table

Now, export the staging table using exp:

$ exp "'/ as sysdba'" tables=SQL_STG_TAB file=SQL_STG_TAB.dmp

Step#5 Import the Staging Table

Copy the dump file to the target database instance and use imp to import it:

$ imp "'/ as sysdba'" file=SQL_STG_TAB.dmp full=y

Step#6 Unpack the Profile

SQL> EXEC DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(replace => TRUE, staging_table_name => 'SQL_STG_TAB');

By following these steps, you’ll successfully move SQL profiles between databases.

Oracle, shell, SQL scripts

Post navigation

Previous Post: Load testing on Oracle 19C RAC with HammerDB
Next Post: Python class import from different folders

Related Posts

  • Jai Shree Ram Oracle
  • Monitor Long Running Job Oracle
  • My Test Case On 21-OCT-2005 Oracle
  • sbind.sql Find Bind variable from sql_id sqlid Oracle
  • Good RAC & Standby Notes Oracle
  • rm_backup_arch_file.ksh Linux/Unix

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Drop all SPM baselines for SQL handle Oracle
  • Pending Distributed Transations Oracle
  • logminer and my_lbu Oracle
  • Goog notes on X$ tables Oracle
  • Roles and Stored Procs II Oracle
  • CPU speed on Linux Linux/Unix
  • How to collect CPU usage on Linux using Shell script Linux/Unix
  • Set Role explaination. Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme