使用user_的表
select a.constraint_name, a.column_name
from user_cons_columns a, user_constraints b
where a.constraint_name = b.constraint_name
and a.constraint_type = 'P'
and b.table_name = 'tablename';
但是可能会存在表格为空
所以使用下列all_table
使用all_的表
select a.constraint_name, a.column_name
from all_cons_columns a, all_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type = 'P'
and a.table_name = 'tablename';