Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Foreign Key constraint Script
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.