加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何获取Oracle中的主键列?

发布时间:2020-12-12 14:37:56 所属栏目:百科 来源:网络整理
导读:我需要获取主键列的名称。 在输入中,我只有表名。 SELECT cols.table_name,cols.column_name,cols.position,cons.status,cons.ownerFROM all_constraints cons,all_cons_columns colsWHERE cols.table_name = 'TABLE_NAME'AND cons.constraint_type = 'P'AN
我需要获取主键列的名称。

在输入中,我只有表名。

SELECT cols.table_name,cols.column_name,cols.position,cons.status,cons.owner
FROM all_constraints cons,all_cons_columns cols
WHERE cols.table_name = 'TABLE_NAME'
AND cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
ORDER BY cols.table_name,cols.position;

请确保“TABLE_NAME”为大写,因为Oracle以大写形式存储表名。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读