请问各位Oralce牛人,有个一个部门表T_Deptment,有一个字段: Deptment,我怎样才能查找到,所有引用Deptment的表呢?

解决方案 »

  1.   

    select * from all_tab_columns where column_name='列名'
      

  2.   

    可以用plsql导出一份所有表结构的脚本,然后文件中查找Deptment
      

  3.   

    select * from all_tab_columns where column_name=UPPER('列名');
    --以处要大写
      

  4.   

    查询一个字段在哪个表或视图
    SELECT * FROM user_tab_columns WHERE lower(column_name) = 'code'  --用你想查询的字段名替换code即可.
      

  5.   

    所有引用了T_Deptment.Deptment字段的表,如果要查询表字段的关联就只有外键关系select 
    a.owner 外键拥有者, 
    a.table_name 外键表, 
    substr(c.column_name,1,127) 外键列, 
    b.owner 主键拥有者, 
    b.table_name 主键表, 
    substr(d.column_name,1,127) 主键列 
    from 
    user_constraints a, 
    user_constraints b, 
    user_cons_columns c, 
    user_cons_columns d 
    where 
        a.r_constraint_name=b.constraint_name 
    and a.constraint_type='R' 
    and b.constraint_type='P' 
    and a.r_owner=b.owner 
    and a.constraint_name=c.constraint_name 
    and b.constraint_name=d.constraint_name 
    and a.owner=c.owner 
    and a.table_name=c.table_name 
    and b.owner=d.owner 
    and b.table_name=d.table_name