拿熟悉的SCOTT用户下的EMP和DEPT表举个例子吧 其中EMP表中的DEPTNO列参照了DEPT表中的DEPTNO列 SQL> select table_name,r_constraint_name from all_constraints where constraint_n ame='FK_DEPTNO';TABLE_NAME R_CONSTRAINT_NAME ------------------------------ ------------------------------ EMP PK_DEPTSQL> select table_name from all_constraints where constraint_name='PK_DEPT';TABLE_NAME ------------------------------ DEPT
dba_con_columns这个在10g的references里好像没找到……
如果你想问FK_DEPTNO我是从而得知的? SQL> select constraint_name from all_constraints where owner='SCOTT' and table_n ame='EMP';CONSTRAINT_NAME ------------------------------ PK_EMP --EMP自己的主键约束 FK_DEPTNO --外键约束
是dba_cons_columns我漏了个s。 lz需求的确是不需要这个view。select table_name from dba_constraints where r_constraint_name=(select constraint_name from dba_constraints where table_name='STUDENT' and constraint_type='P');
create table leader(id number references student(id),name varchar2(10));
我现在只知道student表,不记得leader表了,我想查出leader表,如何查出,请大虾,具体一点,谢谢
其中EMP表中的DEPTNO列参照了DEPT表中的DEPTNO列
SQL> select table_name,r_constraint_name from all_constraints where constraint_n
ame='FK_DEPTNO';TABLE_NAME R_CONSTRAINT_NAME
------------------------------ ------------------------------
EMP PK_DEPTSQL> select table_name from all_constraints where constraint_name='PK_DEPT';TABLE_NAME
------------------------------
DEPT
SQL> select constraint_name from all_constraints where owner='SCOTT' and table_n
ame='EMP';CONSTRAINT_NAME
------------------------------
PK_EMP --EMP自己的主键约束
FK_DEPTNO --外键约束
lz需求的确是不需要这个view。select table_name from dba_constraints
where r_constraint_name=(select constraint_name
from dba_constraints
where table_name='STUDENT'
and constraint_type='P');