Home » RDBMS Server » Server Administration » how to find out referred columns of master table?
how to find out referred columns of master table? [message #371590] Fri, 10 November 2000 03:13 Go to next message
Pravin Deshmukh
Messages: 8
Registered: October 2000
Junior Member
Hi everybody,
I want to find out the parent table and its columns
to which my child table's columns are referring.
I could find out the constraints name ,column name o fthe child table.
Pl. Help!!!
Re: how to find out referred columns of master table? [message #371593 is a reply to message #371590] Fri, 10 November 2000 07:34 Go to previous messageGo to next message
Babu Paul
Messages: 38
Registered: November 2000
Member
Hi,
Basically to get information about these referential constraints we need to look into all_cons_columns and all_constraints tables. The follwing query will ease your job:
SELECT a.table_name child_table, a.column_name child_column, b.table_name parent_table, b.column_name parent_column FROM all_cons_columns a, all_cons_columns b, all_constraints c
WHERE a.table_name = upper('Your table name')
AND b.constraint_name = c.r_constraint_name
AND c.table_name = a.table_name
AND c.constraint_type = 'R'
AND a.constraint_name = c.constraint_name
/

Good Luck
Babu
Re: how to find out referred columns of master table? [message #371601 is a reply to message #371593] Sun, 12 November 2000 22:33 Go to previous messageGo to next message
Pravin Deshmukh
Messages: 8
Registered: October 2000
Junior Member
Hi,
thanks for showing interest in the question.
I want to clarify my question.I just know the forign key namewhich i am finding out from the user_constraints and user_cons_columns table.
I don't know the master table and the colm'n
to which child column is referring.
Re: how to find out referred columns of master table? [message #371603 is a reply to message #371593] Mon, 13 November 2000 04:53 Go to previous messageGo to next message
Babu Paul
Messages: 38
Registered: November 2000
Member
Hi,
It's quite easy to change the query you know, replace table name as a search criteria to point it to your foreign key constraint name. I have modified the query. Please have a look.

SELECT a.table_name child_table, a.column_name child_column, b.table_name parent_table, b.column_name parent_column FROM all_cons_columns a, all_cons_columns b, all_constraints c
WHERE c.constraint_name = upper('your foreign key constraint name')
AND b.constraint_name = c.r_constraint_name
AND c.table_name = a.table_name
AND c.constraint_type = 'R'
AND a.constraint_name = c.constraint_name
/

Good Luck!
Babu
with knowing child table name how to know master table name [message #374087 is a reply to message #371593] Thu, 24 May 2001 04:49 Go to previous message
rajeev B.C
Messages: 1
Registered: May 2001
Junior Member
i hope i can get my ans immediatly
Previous Topic: about type table
Next Topic: View
Goto Forum:
  


Current Time: Mon Dec 23 12:18:40 CST 2024