How to get primary key column in Oracle?

后端 未结 5 1729
悲哀的现实
悲哀的现实 2020-11-29 17:12

I need to get the name of the primary key column.

In the input, I only have the table name.

5条回答
  •  醉梦人生
    2020-11-29 17:42

    Select constraint_name,constraint_type from user_constraints where table_name** **= ‘TABLE_NAME’ ;
    

    (This will list the primary key and then)

    Select column_name,position from user_cons_cloumns where constraint_name=’PK_XYZ’; 
    

    (This will give you the column, here PK_XYZ is the primay key name)

提交回复
热议问题