If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Noob Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-10-03, 08:11
doofusboy doofusboy is offline
Registered User
 
Join Date: Jul 2003
Posts: 24
Noob Question [RESOLVED - THANKS]

Relative newcomer to Oracle. Where does Oracle store information about the Primary Keys for its tables? Specifically, how can I determine, by table, what column(s) are used for the Primary key?

Any assistance is sincerely appreciated.

Last edited by doofusboy; 07-10-03 at 12:48.
Reply With Quote
  #2 (permalink)  
Old 07-10-03, 08:21
billm billm is offline
Drunkard
 
Join Date: Nov 2002
Location: Desk, slightly south of keyboard
Posts: 697
Hi,

Look in the system view 'user constraints'. ie

select * from user_constraints where table_name = 'xxxxx'

etc.

Hth
Bill
Reply With Quote
  #3 (permalink)  
Old 07-10-03, 08:41
doofusboy doofusboy is offline
Registered User
 
Join Date: Jul 2003
Posts: 24
Thanks Bill, but already looked there. It doesn't tell me what column(s) in the table make up the Primary Key. Here's the table def:

SQL> desc user_constraints
Name Null? Type
----------------------------------------- -------- --------------
OWNER NOT NULL VARCHAR2(30)
CONSTRAINT_NAME NOT NULL VARCHAR2(30)
CONSTRAINT_TYPE VARCHAR2(1)
TABLE_NAME NOT NULL VARCHAR2(30)
SEARCH_CONDITION LONG
R_OWNER VARCHAR2(30)
R_CONSTRAINT_NAME VARCHAR2(30)
DELETE_RULE VARCHAR2(9)
STATUS VARCHAR2(8)
DEFERRABLE VARCHAR2(14)
DEFERRED VARCHAR2(9)
VALIDATED VARCHAR2(13)
GENERATED VARCHAR2(14)
BAD VARCHAR2(3)
RELY VARCHAR2(4)
LAST_CHANGE DATE
Reply With Quote
  #4 (permalink)  
Old 07-10-03, 09:55
AlanP AlanP is offline
Registered User
 
Join Date: Mar 2002
Location: Reading, UK
Posts: 1,123
try USER_CONS_COLUMNS. The best way to learn abouth these tables is get something like TOAD (free version available) and just browse the views belong to sys.

Alan
Reply With Quote
  #5 (permalink)  
Old 07-10-03, 11:23
doofusboy doofusboy is offline
Registered User
 
Join Date: Jul 2003
Posts: 24
Talking

THANKS AlanP !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Helps me a lot; exactly what I was looking for.

Anywhere I can learn the names of these sys tables???? I know a few but never the one I need it seems. Have Toad tool......will it tell me the name of these sys tables?
Reply With Quote
  #6 (permalink)  
Old 07-10-03, 11:45
AlanP AlanP is offline
Registered User
 
Join Date: Mar 2002
Location: Reading, UK
Posts: 1,123
Just use schema browser and select the SYS user and the views tab

Alan
Reply With Quote
  #7 (permalink)  
Old 07-10-03, 11:52
doofusboy doofusboy is offline
Registered User
 
Join Date: Jul 2003
Posts: 24
Sorry to keep bothering ya.....but how do I select SYS user?
Reply With Quote
  #8 (permalink)  
Old 07-10-03, 12:23
AlanP AlanP is offline
Registered User
 
Join Date: Mar 2002
Location: Reading, UK
Posts: 1,123
top left hand corner, the drop down combo box.

Alan
Reply With Quote
  #9 (permalink)  
Old 07-10-03, 12:29
The_Duck The_Duck is offline
Registered User
 
Join Date: Jul 2003
Posts: 2,292
yo, goto quest.com and download TOAD for free.

It is a great GUI tool to look up constraints and many other things.
__________________
- The_Duck
you can lead someone to something but they will never learn anything ...
Reply With Quote
  #10 (permalink)  
Old 07-10-03, 12:34
doofusboy doofusboy is offline
Registered User
 
Join Date: Jul 2003
Posts: 24
Talking

Quote:
Originally posted by AlanP
top left hand corner, the drop down combo box.

Alan

Thanks again AlanP........that last assist will be INVALUABLE!!!!!!


....first day here and I like this site already!
Reply With Quote
  #11 (permalink)  
Old 07-10-03, 13:02
billm billm is offline
Drunkard
 
Join Date: Nov 2002
Location: Desk, slightly south of keyboard
Posts: 697
You can also check the system view all_objects etc.

select * from all_objects where owner = 'SYS'

select * from dba_all_objects where owner = 'SYS'

Hth
Bill
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On