Scripts:从shared_pool中创建并删除profile的脚本(注意,此脚本危险比较高,生产环境不要使用)flush_sql10p.sql
2014-05-28 09:16
555 查看
----------------------------------------------------------------------------------------
--
-- File name: flush_sql10p.sql
--
-- Purpose: Flush a single SQL statement.
-
-- Author: Kerry Osborne
--
-- Usage: This scripts prompts for a sql_id.
--
-- sql_id: the sql_id of a statement that is in the shared pool (v$sql)
--
--
-- Description: This scripts creates a SQL Profile on the specified statement and then
-- drops it. This has the side affect of flushing the statement from the
-- shared pool. Well, not always flushing, but generally marking any existing
-- children unusable resulting in a parse the next time the statement is
-- executed. Note, this is the second attempt at this. The first was based
-- on Outlines which was a bit flakey.
--
-- See kerryosborne.oracle-guy.com for additional information.
---------------------------------------------------------------------------------------
accept sql_id -
prompt 'Enter value for sql_id: ' -
default 'X0X0X0X0'
set feedback off
set sqlblanklines on
set serveroutput on for wrap
declare
cl_sql_text clob;
begin
select sql_fulltext into cl_sql_text
from v$sql
where sql_id = '&&sql_id'
and rownum < 2;
dbms_sqltune.import_sql_profile(
sql_text => cl_sql_text,
profile => sqlprof_attr('dummy hint'),
category => 'FLUSH',
name => 'FLUSH_'||'&&sql_id'
);
dbms_sqltune.drop_sql_profile (name => 'FLUSH_'||'&&sql_id');
dbms_output.put_line(' ');
dbms_output.put_line('sql_id: '||'&&sql_id'||' flushed.');
dbms_output.put_line(' ');
exception
when NO_DATA_FOUND then
dbms_output.put_line(' ');
dbms_output.put_line('ERROR: sql_id: '||'&&sql_id'||' not found in v$sqlarea.');
dbms_output.put_line(' ');
end;
/
undef sql_id
set sqlblanklines off
set feedback on
--
-- File name: flush_sql10p.sql
--
-- Purpose: Flush a single SQL statement.
-
-- Author: Kerry Osborne
--
-- Usage: This scripts prompts for a sql_id.
--
-- sql_id: the sql_id of a statement that is in the shared pool (v$sql)
--
--
-- Description: This scripts creates a SQL Profile on the specified statement and then
-- drops it. This has the side affect of flushing the statement from the
-- shared pool. Well, not always flushing, but generally marking any existing
-- children unusable resulting in a parse the next time the statement is
-- executed. Note, this is the second attempt at this. The first was based
-- on Outlines which was a bit flakey.
--
-- See kerryosborne.oracle-guy.com for additional information.
---------------------------------------------------------------------------------------
accept sql_id -
prompt 'Enter value for sql_id: ' -
default 'X0X0X0X0'
set feedback off
set sqlblanklines on
set serveroutput on for wrap
declare
cl_sql_text clob;
begin
select sql_fulltext into cl_sql_text
from v$sql
where sql_id = '&&sql_id'
and rownum < 2;
dbms_sqltune.import_sql_profile(
sql_text => cl_sql_text,
profile => sqlprof_attr('dummy hint'),
category => 'FLUSH',
name => 'FLUSH_'||'&&sql_id'
);
dbms_sqltune.drop_sql_profile (name => 'FLUSH_'||'&&sql_id');
dbms_output.put_line(' ');
dbms_output.put_line('sql_id: '||'&&sql_id'||' flushed.');
dbms_output.put_line(' ');
exception
when NO_DATA_FOUND then
dbms_output.put_line(' ');
dbms_output.put_line('ERROR: sql_id: '||'&&sql_id'||' not found in v$sqlarea.');
dbms_output.put_line(' ');
end;
/
undef sql_id
set sqlblanklines off
set feedback on
相关文章推荐
- shell脚本操作mysql数据库,使用mysql的-e参数可以执行各种sql的(创建,删除,增,删,改、查)等各种操作
- Scripts:创建手工的SQL PROFILE的脚本,老外写的很好用coe_xfr_sql_profile.sql
- 在生产环境中安全执行更新删除SQL脚本的技巧
- Scripts:比较数据库对象的信息(在开发环境中可能需要经常遇到,需要小心使用哦)dba_compare_schemas.sql
- shell脚本操作mysql数据库,使用mysql的-e参数可以执行各种sql的(创建,删除,增,删,改、查)等各种操作
- shell脚本操作mysql数据库,使用mysql的-e参数可以执行各种sql的(创建,删除,增,删,改、查)等各种操作
- Oracle sql 调优:使用虚拟索引在生产环境测试创建索引对数据库性能的影响
- Oracle sql 调优:使用虚拟索引在生产环境测试创建索引对数据库性能的影响
- Scripts:重新编译失效对象的脚本(生产环境慎用)dba_recompile_invalid_objects.sql
- shell脚本操作mysql数据库,使用mysql的-e参数可以执行各种sql的(创建,删除,增,删,改、查)等各种操作
- Scripts:根据sql_id创建sql_profile的脚本(此脚本要慎用)gps.sql
- 使用SQL删除数据库里面用户创建表
- 生产环境使用linux命令的几个注意点
- 使用SQL语句创建和删除约束
- SQL Server数据库中使用sql脚本删除指定表的列
- 使用SQL语句创建和删除约束
- 使用SQL语句创建和删除约束
- 在PL/SQL中使用命令创建和删除表空间
- 生产环境使用ioprofile一定要谨慎
- 使用脚本创建环境变量