如何在主键列中允许重复值? [英] how to possible allow duplicate values in primary key column?

查看:1607
本文介绍了如何在主键列中允许重复值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道主键约束不允许重复值..但我看到我的应用程序旧数据库中的主键列中的重复值...怎么可能?

I knew the primary key constraint does not allow the duplicate values..but i seen that duplicate values in primary key column in my application old database...how is it possible?

推荐答案

主键中不能有重复的值,否则它不会是主键。
You can't have duplicate values in the primary key or else it wouldn't be a primary key.


答案:不可能



措辞主键意味着没有重复的值,它是按设计



您可以在非主键中拥有重复值,这是唯一的方法。
Answer: No it is not possible.

The wording Primary Key imply non duplicate values, it is by design !

You can have duplicate values in Non Primary Key, it is the only way.


As在解决方案1中说明,主键中不能有实际的重复值。

但是,有可能使出现的主键重复但不是。例如,如果主键是文本(nvarchar),则可能发生以下情况:

ABC

ABC 

  ABC

前两个因第二个值的尾随空格而不同。第三个有一个领先的空间。如果您不仔细查看实际值,它们可能出现是重复的。
As stated in Solution 1, you cannot have actual duplicate values in the primary key.
HOWEVER, it may be possible to have primary keys which appear to be duplicates but aren't. For example, if the primary key was textual (nvarchar) then the following could happen:
ABC
ABC 
 ABC
The first two differ by a trailing space on the 2nd value. The 3rd has a leading space. If you don't look carefully at the actual values, they may appear to be duplicates.


这篇关于如何在主键列中允许重复值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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