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
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'