0

I want to create query that result like this :

column_name, constraint_name, constraint_type, referenced_table_name, referenced_column_name

but I got a problem when build the referenced_table_name and referenced_column_name

this is my query

SELECT cols.column_name, cons.constraint_name, cons.constraint_type
FROM all_constraints cons,  all_cons_columns cols
WHERE cols.table_name = 'EMPLOYEES'
AND cons.owner = 'HR'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner

it just show column_name, constraint_name, and constraint_type. How do I show the rest?? Thank's for any help.....

0

1 Answer 1

2

Something like this?

select cols1.column_name
, r1.constraint_name
, r1.constraint_type 
, cols2.table_name
, cols2.column_name
from all_constraints r1
,    all_cons_columns cols1
,    all_cons_columns cols2
WHERE r1.constraint_name = cols1.constraint_name
AND   r1.owner = cols1.owner
and   r1.r_owner = cols2.owner(+)
and   r1.r_constraint_name = cols2.constraint_name(+)
AND cols1.table_name = 'EMPLOYEES' 
AND r1.owner = 'HR' 
/
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.