如何检查Oracle中所有字段是否唯一? [英] How to check if all fields are unique in Oracle?

查看:423
本文介绍了如何检查Oracle中所有字段是否唯一?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查Oracle中所有字段是否唯一?

How to check if all fields are unique in Oracle?

推荐答案

SELECT myColumn, COUNT(*)
FROM myTable
GROUP BY myColumn
HAVING COUNT(*) > 1

这将返回所有myColumn值以及它们的出现次数(如果它们的出现次数大于一)(即它们不是唯一的).

This will return to you all myColumn values along with the number of their occurence if their number of occurences is higher than one (i.e. they are not unique).

如果此查询的结果为空,则此列中具有唯一值.

If the result of this query is empty, then you have unique values in this column.

这篇关于如何检查Oracle中所有字段是否唯一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆