forked from tanelpoder/tpt-oracle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d2.sql
29 lines (24 loc) · 1003 Bytes
/
d2.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
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
-- d.sql using ALL_ views
column d_table_name heading TABLE_NAME format a30
column d_comments heading COMMENTS format a80 word_wrap
break on d_table_name
prompt Show data dictionary views and x$ tables matching the expression "&1" from ALL_TABLES...
select d.table_name d_table_name, d.comments d_comments
from dict d
where upper(d.table_name) like upper('%&1%')
union all
select t.table_name d_table_name, 'BASE TABLE' d_comments
from all_tables t
where t.owner = 'SYS'
and upper(t.table_name) like upper('%&1%')
/
select ft.name d_table_name, (select fvd.view_name
from v$fixed_view_definition fvd
where instr(upper(fvd.view_definition),upper(ft.name)) > 0
and rownum = 1) used_in
from v$fixed_table ft
where ft.type in ('TABLE', 'VIEW')
and replace(upper(ft.name),'V_$','V$') like upper('%&1%')
/