Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent !!...Primary Key problem..

Status
Not open for further replies.

vr76413

Programmer
Feb 26, 2002
65
US
Hi...

I have a bunch of tables....with lots of colums in each of them. How do i know which of the columns in these tables is a primary key, foreign key...etc...?

I did &quot;DESC <table name>&quot;;....but i couldn't make it out.

anyhelp is appreciated.
 
SELECT column_name
FROM all_cons_columns acc, all_constraints aco
WHERE acc.constraint_name = aco.constraint_name
AND constraint_type = 'P'
AND acc.table_name = 'MY_TABLE';
 
The select from sfvb will give you the Primary Key columns.
When setting type equal to 'R' (referencing) then you will get the Foreign Key Columns.
When type='C' you get the Check Constraints.

If you have access to Enterprise Manager it is the easiest to look into the tables to understand all the information in them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top