Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL query to find primary key

80171Jul 26 2002
Can anyone suggest a query that would return all of the columns in the primary key of a table? Information on why I'm asking can be found below.

I'm currently using the following query, but it won't work right if there are unique indexes on the table besides the primary key.
"select column_name from all_ind_columns c, all_indexes i where c.index_owner = i.owner and c.index_name = i.index_name and i.table_owner = {me} and i.table_name = {table_name} and uniqueness = 'UNIQUE'"

The reason I'm interested in the primary key is I need to merge the contents of table A into a table B with the same structure, and before I can do this I need to delete any rows that will cause insertion to fail.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2002
Added on Jul 26 2002
3 comments
960 views