当前位置: 代码迷 >> Oracle管理 >> Oracle 10g sqlplus下怎么查看table的primary key呢
  详细解决方案

Oracle 10g sqlplus下怎么查看table的primary key呢

热度:93   发布时间:2016-04-24 05:48:56.0
Oracle 10g sqlplus下如何查看table的primary key呢?

Oracle   10g   sqlplus下如何查看table的primary   key呢?  

Example:  
SQL>   create   table   test(
    2         id1   number   primary   key,
    3         id2   number,
    4         id3   number
    5     );
SQL>   describe   test;
  Name                                                                       Null?           Type
  --------------------------------------   -----------   ---------------------
  ID1                                                                       NOT   NULL     NUMBER
  ID2                                                                                                 NUMBER
  ID3                                                                                                 NUMBER


------解决方案--------------------
SELECT table_name, constraint_name, constraint_type
FROM sys.user_constraints
WHERE table_name= 'test '

看看是不是出来了?
------解决方案--------------------

select uc.TABLE_NAME,ucc.COLUMN_NAME
from user_constraints uc,user_cons_columns ucc WHERE uc.CONSTRAINT_NAME = ucc.CONSTRAINT_NAME and uc.TABLE_NAME=upper( 'tt1_record ')
and constraint_type= 'P '
  相关解决方案