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
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
you need to look into user_constraints
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
Try looking at USER_CONSTRAINT_COLUMNS (or some such table/view).
ps. Object Names are all in UPPERCASE.
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'
I couldn't remember the correct table name at the time, but...
That's the one!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.