DBMS_sqlTUNE.EXECUTE_TUNING_TASK
1 通过取得来自cursor cache 的sql_id来指定sql语句来建立任务
3 单一sql语句的文本来建立任务
4 通过用awr中相应的sql_id来取得sql语句建立任务
用sql_id获取当sql_id不在v$session a, v$process b, v$sqlarea内,获取到的优化建议为空
DECLARE
my_task_name VARCHAR2(30);
sql_id VARCHAR2(30);
BEGIN
my_task_name := DBMS_sqlTUNE.CREATE_TUNING_TASK
scope => 'comprehensive',
time_limit=>60,
task_name=>'my_sql_tuning_'||sql_id,
description => 'Tuning Task');
DBMS_sqlTUNE.EXECUTE_TUNING_TASK('my_sql_tuning_'||sql_id);
END;
SELECT DBMS_sqlTUNE.REPORT_TUNING_TASK('my_sql_tuning_&sqlid') FROM DUAL
BEGIN dbms_sqltune.drop_tuning_task('my_sql_tuning_520mkxqpf15q8'); END;
BEGIN dbms_sqltune.drop_tuning_task('my_sql_tuning_&sqlid'); END;
DBMS_sqlTUNE.EXECUTE_TUNING_TASK用sql文本获取优化建议
DECLARE
MY_TASK_NAME VARCHAR2(30);
MY_sqlTEXT CLOB;
BEGIN
MY_sqlTEXT :='SELECT * FROM TEST_OBJECT_TTX WHERE OBJECT_ID = :BND';
MY_TASK_NAME := DBMS_sqlTUNE.CREATE_TUNING_TASK(sql_TEXT => MY_sqlTEXT,
BIND_LIST=>sql_BINDS(ANYDATA.CONVERTNUMBER(9)),
USER_NAME => 'NOAP',
ScopE=>'COMPREHENSIVE',
TIME_LIMIT => 60,
TASK_NAME => 'sql_TUNING_TEST',
DESCRIPTION=>'TUNING TASK'
);
END;
select a.program, b.spid, c.sql_text,c.sql_ID
from v$session a, v$process b, v$sqlarea c
where a.paddr = b.addr
and a.sql_hash_value = c.hash_value
and a.username is not null
and c.sql_ID = '7hjb2wh4nprf7'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。