select column_name from all_cons_columns where table_name='TT' and owner='SCOTT';

解决方案 »

  1.   

    SQL> select column_name,tt.CONSTRAINT_TYPE from all_cons_columns t,ALL_CONSTRAINTS tt
      2  where t.table_name=tt.table_name and t.owner=tt.owner
      3  and t.CONSTRAINT_NAME=tt.CONSTRAINT_NAME and tt.CONSTRAINT_TYPE='P'
      4  and t.table_name='DEPT'  and t.owner='SCOTT';COLUMN_NAME
    --------------------------------------------------------------------------------
    C
    -
    DEPTNO
    P
    已用时间:  00: 00: 00.01
    SQL>
      

  2.   

    或者
    SQL> select COLUMN_NAME from user_cons_columns where table_name = 'EMP' and owner='SCOTT'
      2  and CONSTRAINT_NAME like 'PK_%';COLUMN_NAME
    --------------------------------------------------------------------------------
    EMPNO已用时间:  00: 00: 00.20
    SQL>