唯一列可以接受多个空值吗? [英] can unique column accept multiple null value?

查看:103
本文介绍了唯一列可以接受多个空值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们.
是唯一键接受空值.在我的应用程序中,它不接受多个空值.但是从我的研究开始,它接受唯一列的空值.假设它接受,我如何修改我的唯一列表以接受空值

谢谢

Hi friends.
Is Unique key accept null value. In my application it does not accept multiple null value.but from i studied it accept null for unique column.suppose it accept, how can i modify my unique column table for accepting null value

Advance Thanks

推荐答案

逻辑上,任何允许包含非重复(唯一)值的键都是唯一键,NULL是SQL Server中允许的值,因此它可以像任何其他值一样,在单个时间中具有NULL.

但是按照标准,没有这样的规则,只允许一个NULL.因此,使用SQL Server时,您只能停留一次NULL值.
参考:
http://en.wikipedia.org/wiki/Unique_key [ http://connect.microsoft.com/SQLServer/feedback/details/299229/change-unique-constraint-to-allow-multiple-null-values [
Logically, any key which is allowed to contain non duplicate (unique) values is a unique key, NULL is a permissible value in SQL Server , so it can have NULL for a single time just like any other value.

But as per standards, there is no such rule that only ONE NULL is allowed. So, with SQL Server you are stuck with just one time NULL value.
Refer:
http://en.wikipedia.org/wiki/Unique_key[^]
http://connect.microsoft.com/SQLServer/feedback/details/299229/change-unique-constraint-to-allow-multiple-null-values[^]


如果您的意思是主键列,则否-您不能有空的主键.

如果您的意思是在可为空的列上使用唯一索引,那么...不是一个好主意...但是...这是有可能的.

在这里看看:
http://sqlservercodebook.blogspot .co.uk/2008/04/multiple-null-values-in-unique-index-in.html [
If you mean on a primary key column, then no - you can''t have null primary keys.

If you mean a unique index on a nullable column, well...not really a good idea...but...it is possible.

Have a look here: http://sqlservercodebook.blogspot.co.uk/2008/04/multiple-null-values-in-unique-index-in.html[^]


这篇关于唯一列可以接受多个空值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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