Q
Problem solve Get help with specific problems with your technologies, process and projects.

SQL statement to return primary keys

I am looking for an SQL statement that would return me the primary key(s) and the datatype of the key(s). Do you know of one?

To check on your primary key constraints, and their columns, you can use the following query:

SELECT x.constraint_name, x.table_name, y.column_name,
y.position
FROM user_constraints x, user_cons_columns y
WHERE x.constraint_name=y.constraint_name
AND x.constraint_type='P'
ORDER BY 1,2,4;

For More Information


This was last published in June 2003

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close