有一表 如:student(id number primary key,name varchar2(10));
另外有一个表或多个表外键依赖于id ,如何的找出这些表?

解决方案 »

  1.   

    create table student(id number primary key ,name varchar2(10));
    create table leader(id number references student(id),name varchar2(10));
    我现在只知道student表,不记得leader表了,我想查出leader表,如何查出,请大虾,具体一点,谢谢
      

  2.   

    就是从我说的那两个视图中看。你先看哪些表有外键约束,再看其父表是student的。这样就找出leader表了。
      

  3.   

    拿熟悉的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
      

  4.   

    dba_con_columns这个在10g的references里好像没找到……
      

  5.   

    如果你想问FK_DEPTNO我是从而得知的?
    SQL> select constraint_name from all_constraints where owner='SCOTT' and table_n
    ame='EMP';CONSTRAINT_NAME
    ------------------------------
    PK_EMP --EMP自己的主键约束
    FK_DEPTNO --外键约束
      

  6.   

    是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');