Hi All,
Help me out to find all child tables for a table.
Consider a table AAA having 5 child tables i.e
Table Name
BBB
CCC
DDD
EEE
FFF
to get the above result i can get from below SQL
SELECT A.table_name, A.constraint_name,B.COLUMN_NAME FROM user_constraints A , user_cons_columns B
WHERE r_constraint_name in (SELECT constraint_name FROM user_constraints WHERE constraint_type in ('P','U') AND table_name = 'AAA' ) AND A.constraint_name=B.constraint_name
AND B.COLUMN_NAME LIKE '%ID'
ORDER BY Table_name DESC;
output:
Table Name Constraint name Column Name
BBB BBB_FK BBCOL1
CCC CCC_FK CCCol1
DDD DDD_FK DDCol1
EEE EEE_FK EECol1
FFF FFF_FK FFCol1
but my problem is i need to get all child table of child table
Suppose
Table Name
BBB
BA1
BA2
BBA1
BBB2
BA3
CCC
CA1
CA2
DDD
DA1
DDA1
DB2
.
.
.
etc
i will give input as AAA then SQL need to display all child table names.. How can archive it through SQL?
Thanks & Regards
Sami.