请问高手,我用的是ORACLE 里面有很多表,我想查出没有主键的表,怎么查。

解决方案 »

  1.   

    可以用ALL_OBJECT之类的系统表,用主键所属的表和各个表名关联查询
      

  2.   

    try:select * from user_tables a where not exists
    (select * from user_constraints b where a.table_name=b.table_name and b.constraint_type='P');
      

  3.   

    select table_name
    from user_tables a
    where not exists(
    select * from user_constraints b where b.constraint_type='P' and a.table_name=b.table_name)
      

  4.   

    引用 1 楼 hebo2005 的回复:
    可以用ALL_OBJECT之类的系统表,用主键所属的表和各个表名关联查询 
     
    正解。
      

  5.   

    SELECT DISTINCT table_name FROM user_constraints  A
    WHERE NOT EXISTS(SELECT 1 FROM user_constraints B WHERE CONSTRAINT_TYPE='P' AND TABLE_NAME=A.TABLE_NAME)