-
Notifications
You must be signed in to change notification settings - Fork 35
/
cons.sql
61 lines (57 loc) · 1.76 KB
/
cons.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
prompt ===========================================================
prompt * Info from dba_constraints
prompt * Usage: @cons table [owner]
prompt ===========================================================
@inc/input_vars_init;
@inc/main_with_params_only;
col tab format a40;
col name format a30;
col cols format a40;
col conditions format a40;
col delete_rule format a8;
col r_constraint format a40;
col index_owner format a30;
col index_name format a30;
col status format a10;
select
c.owner||'.'||c.table_name as tab
,c.constraint_name as name
,c.constraint_type as type
,(select
xmlquery('string-join(.,",")'
passing xmlagg(xmlelement(COL,cc.column_name) order by cc.position)
returning content
).getstringval() xx
from dba_cons_columns cc
where c.owner = cc.owner
and c.constraint_name = cc.constraint_name
) as cols
,c.search_condition as conditions
,nvl2(c.r_owner,c.r_owner||'.'||c.r_constraint_name,'') as r_constraint
,c.delete_rule
,c.status
,c.last_change
,nvl2(c.index_owner,c.index_owner||'.'||c.index_name,'') as index_name
,c.deferrable
,c.deferred
,c.validated
,c.generated
,c.bad
,c.rely
,c.invalid
,c.view_related
from dba_constraints c
where c.owner like upper(nvl('&2','%'))
and c.table_name like upper('&1')
/
col tab clear;
col name clear;
col cols clear;
col conditions clear;
col delete_rule clear;
col r_constraint clear;
col index_owner clear;
col index_name clear;
col status clear;
/* end main_with_params_only */
@inc/input_vars_undef;