Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







Migrating Oracle SQL Profiles

Oracle Database Tips by Donald BurlesonFebruary 12, 2015

Migrating Oracle SQL Profiles

Question:  I am moving my database and I want to be able to export and migrate my SQL profiles.  How do your export/import migration of SQL profiles.

Answer:  SQL Profiles can be exported and imported just like stored outlines, but with a different procedure.  There is a different procedure for migrating SQL profiles in Oracle 10g release one, and the migration procedure changes in Oracle 10g release two.

Migrating SQL Profiles in Oracle 10 release 1

Prior to Oracle 10g release 2, you can migrate SQL profiles with the dbms_sqltune.import_sql_profile procedure.  Incidentally, the import_sql_profile procedure is used to swap SQL profiles so that you can change SQL execution plans without touching the SQL source code.  Balaji R offers these steps to migrate SQL profiles in Oracle 10g release one:

SQL Profile consists of auxiliary statistics specific to that statement and are stored as profile attributes in the data dictionary, which can be retrieved from the two tables SQLPROF$ and SQLPROF$ATTR.

In the source I have a profile called 'SYS_SQLPROF_091112150758738', which can be retrieved as below:
select sp.sp_name, sa.attr#, sa.attr_val
where sp.signature = sa.signature
and sp.category = sp.category
and sp.sp_name = 'SYS_SQLPROF_091112150758738'
order by sp.sp_name, sa.attr#
------------------------------ ---------- ----------------------------------------
SYS_SQLPROF_091112150758738 1 FIRST_ROWS(1)

Now I have the attributes from the source, which can be imported as a profile into the destination using the import_sql_profile procedure of the dbms_sqltune package as below: 

exec dbms_sqltune.import_sql_profile(name => 'SYS_SQLPROF_091112150758738',description => 'SQL profile created for porting the profile from 10gR1',category => 'DEFAULT',sql_text => 'select XXXXXXXXX from XXXXXXX where XXXXXXXXX and XXXXXXXXXXX',profile => sqlprof_attr('FIRST_ROWS(1)','OPTIMIZER_FEATURES_ENABLE(default)'),replace => FALSE,force_match => FALSE);

After the import I wanted to make sure of two things :

1. The profile is used in the statement.

2. I have the optimal plan as I had in the source DB.

Both can be checked with the explain plan as below:

explain plan for

I had a similar plan and also could see the below in the explain plan which says the profile is used.  I am not sure if this is supported but did work for me.

Migrating SQL Profiles in Oracle 10 release 2 and beyond

In Oracle 10g release 2 and beyond, the MOSC document ID 457531.1 provides complete steps for migrating SQL profiles.  The documentation notes that you export SQL profiles with the dbms_sqltune package, using these steps:

Import/Export SQL Tuning Sets and SQL Profiles

You use DBMS_SQLTUNE subprograms to move SQL Profiles and SQL Tuning Sets from one system to another using a common programmatic model. In both cases, you create a staging table on the source system and populate that staging table with the relevant data.

You then move that staging table to the destination system following the method of your choice (such as datapump, import/export, or database link), where it is used to reconstitute the objects in their original form.

In a nutshell, here are the steps to migrate SQL profiles in 10gr2 and beyond:

Step 1:  create_stgtab_sqlprof = Create a SQL Profile storage table

Step 2:  pack_stgtab_sqlprof = Populate the storage table with SQL Profiles

Step 3:  expdp/impdb = Next, you migrate the table anywhere you like, using standard Oracle utilities or CTAS over a database link.

Step 4:  unpack_stgtab_sqlset = Unpacks the SQL profiles on the destination database

Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.