Created
September 16, 2014 13:57
-
-
Save uilian/08aadb62f6ab42030cf1 to your computer and use it in GitHub Desktop.
Identify table references
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
distinct * | |
from | |
( | |
select | |
upper(:table_name) tabela, | |
'is refereced by' behaviour, | |
b.table_name | |
from | |
all_constraints a, | |
all_tables b | |
where | |
a.constraint_type = 'R' and | |
a.table_name = b.table_name and | |
b.owner = :owner and | |
a.r_constraint_name in | |
(select x.constraint_name from all_constraints x, all_tables y | |
where x.constraint_type in ('P', 'U') and x.table_name = UPPER(:table_name) and x.table_name = y.table_name and y.owner = :owner) | |
union all | |
select | |
upper(:table_name) tabela, | |
'has references to' behavior, | |
a.table_name | |
from | |
all_constraints a, | |
all_tables b | |
where | |
a.table_name = b.table_name and | |
b.owner = :owner and | |
constraint_name in | |
(select r_constraint_name from all_constraints x, all_tables y where y.owner = :owner and x.table_name = UPPER(:table_name) and y.table_name = x.table_name) | |
) | |
order by 1,2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment