Re: Query the name of the primary key of a table [message #371432] |
Wed, 18 October 2000 13:29 |
Prem
Messages: 79 Registered: August 1998
|
Member |
|
|
Stefan,
Run this query in SQL*Plus to test. It will prompt you for the table name. Enter the table name (all in caps, or you may have to change the query using upper())
select column_name from user_cons_columns
where constraint_name in (select constraint_name from user_constraints
where constraint_type = 'P' and table_name = '&TABLENAME')
This will display the column which is a primary key. If your primary key is composite (more than 1 column form a primary key), it will display all these columns.
hth
Prem :)
|
|
|