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
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
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.