Home » SQL & PL/SQL » SQL & PL/SQL » Retrieving a primary key
icon5.gif  Retrieving a primary key [message #325212] Thu, 05 June 2008 05:23 Go to next message
kuwait
Messages: 52
Registered: October 2007
Member
Hello

Please can anyone tell me how can I retrieve a primary key for a table by using sqlplus?
I tried google and find some code but it was not working.

Thanks

[Updated on: Thu, 05 June 2008 05:28]

Report message to a moderator

Re: Retrieving a primary key [message #325215 is a reply to message #325212] Thu, 05 June 2008 05:29 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
dba_constraints, dba_cons_columns

Regards
Michel
Re: Retrieving a primary key [message #325221 is a reply to message #325212] Thu, 05 June 2008 05:43 Go to previous messageGo to next message
ttparavindh
Messages: 22
Registered: December 2006
Location: Bangalore,India
Junior Member

SELECT CONSTRAINT_NAME,TABLE_NAME FROM USER/ALL/DBA_CONS_COLUMNS WHERE TABLE_NAME='EMP';

or

SELECT CONSTRAINT_NAME,CONSTRAINT_TYPE,TABLE_NAME FROM USER/ALL/DBA_CONSTRAINTS WHERE TABLE_NAME='EMP';

Regards,
Aravindh
Re: Retrieving a primary key [message #325230 is a reply to message #325221] Thu, 05 June 2008 05:50 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
And what does this add to waht I posted?

Regards
Michel
Re: Retrieving a primary key [message #325864 is a reply to message #325212] Mon, 09 June 2008 05:06 Go to previous message
kuwait
Messages: 52
Registered: October 2007
Member
Thanks all I've did what you've suggested
Previous Topic: Insert data in diff schema
Next Topic: views could not be updated :no-key reserved table
Goto Forum:
  


Current Time: Sun Dec 11 04:16:44 CST 2016

Total time taken to generate the page: 0.06305 seconds