Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
46 views3 pages

Oracle SQL Profile Management Guide

The document discusses how to manage SQL profiles in an Oracle database. It covers how to create a tuning task, execute the task, view reports, and drop tasks. It also covers exporting, importing, packing, and unpacking SQL profiles to staging tables for migration between databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views3 pages

Oracle SQL Profile Management Guide

The document discusses how to manage SQL profiles in an Oracle database. It covers how to create a tuning task, execute the task, view reports, and drop tasks. It also covers exporting, importing, packing, and unpacking SQL profiles to staging tables for migration between databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

https://smarttechways.

com/2017/12/20/manage-the-sql-profile-in-the-oracle-database/

7vh59j7knyaaz

1. Create Tuning Task

DECLARE
l_sql_tune_task_id VARCHAR2(100);
BEGIN
l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (
sql_id => '7vh59j7knyaaz',
scope => DBMS_SQLTUNE.scope_comprehensive,
time_limit => 500,
task_name => '7vh59j7knyaaz_tuning_task11',
description => 'Tuning task1 for statement
7vh59j7knyaaz');
DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
END;
/

2. Execute Tuning task:

EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => '7vh59j7knyaaz_tuning_task11');

3. Get the Tuning advisor report.

set long 65536


set longchunksize 65536
set linesize 100
select dbms_sqltune.report_tuning_task('7vh59j7knyaaz_tuning_task11') from dual;

4. Get list of tuning task present in database:

SELECT TASK_NAME, STATUS FROM DBA_ADVISOR_LOG WHERE


TASK_NAME='7vh59j7knyaaz_tuning_task11';

5. Drop a tuning task:

execute dbms_sqltune.drop_tuning_task('7vh59j7knyaaz_tuning_task11');

1. Create a staging table

exec
DBMS_SQLTUNE.CREATE_STGTAB_SQLPROF(table_name=>'PROFILE_7vh59j7knyaaz',schema_name=
>'REVERA_OWNER');

2. Pack the profiles to the staging table

exec DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (staging_table_name


=>'PROFILE_7vh59j7knyaaz',STAGING_SCHEMA_OWNER =>
'REVERA_OWNER',profile_name=>'coe_7vh59j7knyaaz_2479972749');

exec DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (staging_table_name


=>'PROFILE_7vh59j7knyaaz',STAGING_SCHEMA_OWNER
=>'REVERA_OWNER',profile_name=>'coe_7vh59j7knyaaz_2479972749');

3. Export the staging table:

nohup expdp \'/ as sysdba\' directory=SQL_PROFILE_JJ_L1


dumpfile=PROFILE_7vh59j7knyaaz.dmp logfile=exp_PROFILE_7vh59j7knyaaz.log
tables=REVERA_OWNER.PROFILE_7vh59j7knyaaz &

4. copy the dump to target db and import the table.

nohup impdp \'/ as sysdba\' directory=SQL_PROFILE_JJ_L1


dumpfile=PROFILE_7vh59j7knyaaz.dmp logfile=imp_sqlprofile_PROFILE_7vh59j7knyaaz.log
&

5. Unpack the sql profiles

EXEC DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(REPLACE => TRUE,staging_table_name =>


'PROFILE_7vh59j7knyaaz');

create directory SQL_PROFILE_JJ_L1 as '/BACKUP_L1/sql_profile';

select name from v$database;

col name for a30


col sql_text for a50
col created for a30

select NAME,SQL_TEXT,CREATED from dba_sql_profiles where


name='coe_7vh59j7knyaaz_881051899';

EXEC DBMS_SQLTUNE.ALTER_SQL_PROFILE(name
=>'coe_7vh59j7knyaaz_2479972749',attribute_name=>'STATUS',value=>'ENABLED');

select inst_id,sql_id,status, plan_hash_value, sql_profile, sql_plan_baseline,


executions, buffer_gets/decode(executions,0,1,executions) avg_gets,
elapsed_time/decode(executions,0,1,executions)/1000000 avg_secs from gv$sql
where sql_id='f4azr8qqd9djf' order by 1;

COLUMN category FORMAT a10


COLUMN sql_text FORMAT a20
SELECT NAME,type, SQL_TEXT, CATEGORY, STATUS FROM DBA_SQL_PROFILES where
name='coe_7vh59j7knyaaz_881051899';
BEGIN
DBMS_SQLTUNE.ALTER_SQL_PROFILE(
name => 'coe_7vh59j7knyaaz_881051899',
attribute_name => 'STATUS',
value => 'DISABLED');
END;
/

select inst_id,sql_id, plan_hash_value, sql_profile, sql_plan_baseline, executions,


buffer_gets/decode(executions,0,1,executions) avg_gets,
elapsed_time/decode(executions,0,1,executions)/1000000 avg_secs from gv$sql where
sql_id='f4azr8qqd9djf' order by 1;

select distinct plan_hash_value, timestamp from dba_hist_sql_plan where


sql_id='7vh59j7knyaaz';

SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR('7vh59j7knyaaz',0,'ALL'));

select distinct plan_hash_value, timestamp from dba_hist_sql_plan where


sql_id='7vh59j7knyaaz';

You might also like