通过子表查父表,通过父表查子表

两上表student 和 teacher 其中,student表外键约束依赖于teacher表

情形一:已知student 表,如何找到student的父表?

 

select table_name from user_constraints where constraint_name = (select r_constraint_name from user_constraints where table_name = 'STUDENT' and constraint_type = 'R')


情形二:已知teacher表,如何找到teacher的子表?

 

select table_name from user_constraints where r_constraint_name = (select constraint_name from user_constraints where table_name = 'TEACHER' and constraint_type = 'P')


 

你可能感兴趣的:(Oracle学习)