Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Foreign Key constraint Script

Re: Foreign Key constraint Script

From: <bosco_at_ibsplc.com>
Date: Tue, 18 Jul 2000 14:08:21 +0530
Message-Id: <10562.112241@fatcity.com>


Hello Ashish, Hello All,

Please find here a script which would show you the foreign keys on a table .It shows the other tables which are referencing this table

select c.TABLE_NAME, c.CONSTRAINT_NAME, c.R_CONSTRAINT_NAME, rc.TABLE_NAME,

       substr(col.COLUMN_NAME,1,30)
from user_constraints c, user_cons_columns col, user_constraints rc where c.TABLE_NAME like upper('&TableName')   and rc.CONSTRAINT_NAME = c.R_CONSTRAINT_NAME   and col.CONSTRAINT_NAME = c.CONSTRAINT_NAME order by c.TABLE_NAME, c.CONSTRAINT_NAME, col.POSITION;

Pass the table name as a parameter
Have fun,
Bosco

Hi All,
Does any one have any script that will tell me a Table has been referenced (foreign key) in how many other tables. I had a tough time droping a table since
it was refered by so many other table.
I tried looking user_constraints but it doesn't give you information about primary table.
TIA.


Received on Tue Jul 18 2000 - 03:38:21 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US