Home » SQL & PL/SQL » SQL & PL/SQL » How to find primary key ,foreign key , index and sequence associated to a table
How to find primary key ,foreign key , index and sequence associated to a table [message #617273] Thu, 26 June 2014 11:33 Go to next message
gorants
Messages: 85
Registered: May 2014
Location: ATL
Member
Hello All.

How to find primary key, foreign key, unique key, index and sequences associated to a table

Thanks,
Re: How to find primary key ,foreign key , index and sequence associated to a table [message #617274 is a reply to message #617273] Thu, 26 June 2014 11:42 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
The first 3 (PK, FK, unique) are all revealed in the dba_constraints view.


As for sequences ... while the primary use of a sequence is probably to populate a PK, there is no inherent, dictionary-defined connection between a sequence and a table. In reality, a sequence's sole purpose is to provide a number. Period. Full stop. How you use that number -- say, to populate a PK column -- is entirely up to you and is implemented in your code. That code could be a trigger or procedure, it could be application code written in any language and residing anywhere. If it is NOT implemented as a trigger, there is no guarantee/enforcement of its use as a PK. And there is also no guarantee that sequence is used for only one table.
Re: How to find primary key ,foreign key , index and sequence associated to a table [message #617275 is a reply to message #617273] Thu, 26 June 2014 11:42 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
SEQUENCE is an independent object with NO association to any table!

query ALL_CONSTRAINTS & ALL_INDEXES


Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and please read http://www.orafaq.com/forum/t/174502/102589/
Previous Topic: Incorrect number of seconds returned from function
Next Topic: How to enforce key uniqueness in a temporal table?
Goto Forum:
  


Current Time: Fri Apr 26 07:07:16 CDT 2024