如何在 Access 索引中允许重复的空白?
使用 Access 2007。我有一个字段,我只想包含唯一的非空白值,但允许多个空白值。我尝试使用 Unique: Yes 和 Ignore Nulls: Yes 设置索引。我可以手动输入此字段为空的记录,但是当我尝试使用 SQL 插入此字段为空值的记录时,例如
insert into mytable (field1, blanksOK, field3) values ("xyz","","123")
,Access 会给出一条错误消息:“...没有添加 1 条记录” (s) 由于关键违规而被添加到表中...”
将“忽略空值”从“是”更改为“否”似乎没有任何区别。
如何允许重复的空白,但防止重复的非空白?
Using Access 2007. I have a field that I want to only have unique non-blank values, but allow multiple blank values. I tried setting an index with Unique: Yes and Ignore Nulls: Yes. I can manually enter records that have this field blank, but when I try to use SQL to insert a record that has a blank value for this field, e.g.
insert into mytable (field1, blanksOK, field3) values ("xyz","","123")
then Access gives me an error message: "...didn't add 1 record(s) to the table due to key violations..."
Changing Ignore Nulls from Yes to No doesn't seem to make any difference.
How can I make duplicate blanks allowable, but prevent duplicate non-blanks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的印象是空白对于 Access 中的索引键无效,因此出现错误。根据定义,键必须包含非空白条目。空值是可以的,因为空值是一个索引值。
I was under the impression blanks are not valid for indexed keys in Access, hence the error. Keys must have non blank entries by definition. nulls are OK as described as null is an indexabe value.