.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

How do I determine if a table has any primary key in Oracle?

Posted By: Dhivakaran     Posted Date: October 27, 2010    Points:2   Category :Sql Server
How do I determine if a table has any primary key in Oracle?

Responses
Author: Syed Shakeer Hussain             
Posted Date: October 27, 2010     Points: 5   

Hi,

Run the below query to get PrimaryKeys in Oracle

SELECT * FROM ALL_CONS_COLUMNS A JOIN ALL_CONSTRAINTS C ON A.CONSTRAINT_NAME = C.CONSTRAINT_NAME WHERE C.TABLE_NAME = <your table> AND C.CONSTRAINT_TYPE = 'P'




Author: Asha.MP             
Posted Date: October 28, 2010     Points: 5   

Hi..

You can use this query to get the primary key used in the table

SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE (TABLE_NAME = 'YourTableName')
ORDER BY TABLE_NAME, COLUMN_NAME

'YourTableName'-->indicates the table which you want get the information

Thanks and Regards,
Asha.mp


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend