select column_name from all_cons_columns where table_name='表名称(主要要大写)' and owner='(表的所有者)' and position is not null

解决方案 »

  1.   

    select column_name from all_cons_columns where table_name='表名称(注意要大写)' and owner='表的所有者(也要大写)' and position is not null
      

  2.   

    条件owner不写也可,但要保证你的所有表空间中无重复tablename
      

  3.   

    详细点就是,我要写一个通用的方法,只用表名做参数,得到这个表的关键字,应该是可以的吧,我不知道怎么实现。
    To rainxue:
       你的方法好像不行吧,position is not null不一定就是primary key啊。
      

  4.   

    select column_name from user_cons_columns where constraint_name in 
    (select constraint_name from user_constraints where table_name=
     yourtablename and constraint_type='P')