SunQuest
           Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old June 28th, 2004, 06:11 PM
sriramc sriramc is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 sriramc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Find the Foriegn Keys

Can anyone help in finding all the foriegn keys of a particular table and to which table and column it is referenced to?

Thanks

Ram

Reply With Quote
  #2  
Old June 29th, 2004, 01:01 AM
galith_haham galith_haham is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 64 galith_haham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 25 m 17 sec
Reputation Power: 5
Hi,

run the following from the application schema (if you are the dba replace the user_constraints with dba_constraints)

select constraint_name from user_constraints
where CONSTRAINT_TYPE='R'
and table_name=<enter the name of your table>;

regards,
Galit.

Reply With Quote
  #3  
Old June 29th, 2004, 11:59 AM
sriramc sriramc is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 sriramc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks,

But this will just get the constraint name of the table which is of type "r". Now this is just the name that I created, but how do I get the name of the fields in the other table to whom it is related?

Ram


Quote:
Originally Posted by galith_haham
Hi,

run the following from the application schema (if you are the dba replace the user_constraints with dba_constraints)

select constraint_name from user_constraints
where CONSTRAINT_TYPE='R'
and table_name=<enter the name of your table>;

regards,
Galit.

Reply With Quote
  #4  
Old June 29th, 2004, 01:35 PM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
SELECT a.table_name, a.column_name,
b.constraint_name, b.constraint_type
FROM user_cons_columns a, user_constraints b, user_tab_columns c
WHERE a.table_name = 'EMP'
AND a.table_name = b.table_name
AND b.table_name = c.table_name
AND a.constraint_name = b.constraint_name
AND a.column_name = c.column_name
/

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Find the Foriegn Keys


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway