Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Get the primary key name of a table
Hello!
Thank you for your advices.
I now use following statement to get the primary key of a table:
SELECT COL.COLUMN_NAME FROM USER_CONS_COLUMNS COL, USER_CONSTRAINTS CON WHERE COL.TABLE_NAME = 'TABLENAME' AND COL.TABLE_NAME = CON.TABLE_NAME AND COL.CONSTRAINT_NAME = CON.CONSTRAINT_NAME AND CON.CONSTRAINT_TYPE='P'; I hope this statement works in all oracle versions.
Robert Received on Thu Mar 17 2005 - 01:44:14 CST