-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathfind20.sql
31 lines (29 loc) · 895 Bytes
/
find20.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
col if_wrh new_val _if_wrh noprint;
col target new_val _target noprint;
select
decode(count(*),1,'' ,'--' ) as if_wrh
,decode(count(*),1,'SYS.WRH$_SQLTEXT','DBA_HIST_SQLTEXT') as target
from all_objects o where o.owner='SYS' and object_name='WRH$_SQLTEXT' and object_type='TABLE'
/
col awr_sql_text format a150;
col sql_id format a13;
select *
from (
select
dbid as dbid
,sql_id as sql_id
&_IF_WRH ,snap_id as snap_id
&_IF_WRH ,ref_count as ref_count
,sql_text as awr_sql_text
,command_type as command_type
from
&_target
where upper(sql_text) like upper('&1')
order by
dbid
&_IF_WRH ,SNAP_ID desc
) tmp
where rownum<=20
/
undef _if_wrh _target
col awr_sql_text clear;