简体   繁体   English

不允许重复

[英]do not allow duplicates

I am importing data from an access table to SQL.我正在将数据从访问表导入 SQL。 I have a primary key is SQL "quoteID" which obviously doesn't allow duplicates but I'm looking to add that requirement to another field.我有一个主键是 SQL "quoteID",它显然不允许重复,但我希望将该要求添加到另一个字段中。

Can't seem to find where to set that?似乎找不到在哪里设置? perhaps it has to do with the field type??也许它与字段类型有关?

You can require that a column be unique using a unique constraint or unique index:您可以使用唯一约束或唯一索引来要求列是唯一的:

alter table t add constraint unq_t_col unique (col);

or:或者:

create unique index unq_t_col on t(col);

Make the field a primary key of the table.将该字段作为表的主键。 Or put an index on that field that enforces unique values.或者在该字段上放置一个强制唯一值的索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM