SQL> select column_name from user_cons_columns where rownum < 5;COLUMN_NAME
------------------------------------
STATION_UP_ID
STATION_ID
USER_ID
FUNCTION_IDExecuted in 0.016 secondsSQL>
------------------------------------
STATION_UP_ID
STATION_ID
USER_ID
FUNCTION_IDExecuted in 0.016 secondsSQL>
表示只选4条记录。
from user_constraints
where conSTRAINT_NAME not like 'SYS_%'
and constraint_type='P'
order by CONSTRAINT_NAME,table_name;
select owner,CONSTRAINT_NAME,TABLE_NAME
from user_constraints
where conSTRAINT_NAME not like 'SYS_%'
and constraint_type='P'
order by CONSTRAINT_NAME,table_name;
他已经说得很清楚了,使用该查询可以得到所有得表得主键约束
其实最简单得方法是利用plsql develop工具或者oracle自带的dba studio 图形化工具可以清楚的查看
每一个表的结构(包括主外键、约束等等)
from user_constraints
where conSTRAINT_NAME not like 'SYS_%'
and constraint_type='P'
and table_name='TABLENAME';
最后一行的TABLENAME为你要查找的表名,必须为大写.
select table_name,constraint_name,column_name
From user_cons_columns
Where table_name = '表名'