如何让数据表某一字段只能输入唯一值

如题所述

用字段id举个例子,有两种情况:
1、新建表字段
create table test (id varchar(32) primary key not null);

2、已有表和字段id
alter table test add constraint pk_id primary key;

希望能帮到你!
温馨提示:答案为网友推荐,仅供参考
相似回答