0

Hi Guys,
Can you please let me know if there is a sql command to list PK , Child and Parent of an identical table in oracle?
Lets say I have a table called City , how can I get those information using SQL?

Thanks

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by hfx642
0

Hi debasisdas
Thanks for you comment,
I used the user_constraints as u said and a SQL like:

select * from user_constraints where table_name = 'Emp' and CONSTRAINT_TYPE = 'P';

Now I am getting a the constraint name but not the Primary key column name!Can you please let me know how I can get the name of column which is the primary key(s) of the 'Emp' Table?

Best Regards

0

Try looking at USER_CONSTRAINT_COLUMNS (or some such table/view).

ps. Object Names are all in UPPERCASE.

Edited by hfx642: n/a

0

try this

select u1.* from user_cons_columns u1 ,user_constraints u2
where u1.table_name = u2.table_name
and u1.owner = u2.owner
and u1.table_name = upper ('table_name')
and u2.constraint_type = 'P'
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.