[20240308]建立完善colour.sql脚本.txt
--//想观察sql优化效果,发现awr不再记录该语句执行情况。平时执行太少,有时候查询v$sqlarea也没有结果,
--//也就是该语句根本不在共享池里面。
--//为了记录该语句的执行情况需要使用dbms_workload_repository.add_colored_sql命令,写一个脚本方便管理。
--//该脚本仅仅生成执行语句,要手工copy and paste执行。
$ cat colour.sql
-- Copyright 2023 lfree. All rights reserved.
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms and conditions.
----------------------------------------------------------------------------------------------
--
-- Name: colour.sql
-- Purpose: Generate the dbms_workload_repository.XXX_colored_sql and query of sys.wrm$_colored_sql
-- scripts
-- Author: lfree
-- Usage:
-- @colour <sql_id>
--
-- Other:
-- To simply generate the execution script
--
-----------------------------------------------------------------------------------------------
prompt
prompt add and remove from awr
prompt exec dbms_workload_repository.add_colored_sql('&&1');;
prompt exec dbms_workload_repository.remove_colored_sql('&&1');
prompt
prompt query sys.wrm$_colored_sql
prompt column owner format 99999999
prompt select * from sys.wrm$_colored_sql where sql_id='&&1';;
prompt select * from sys.wrm$_colored_sql ;;
prompt column owner format a20
prompt
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3008669/ ,如需转载,请注明出处,否则将追究法律责任。