天天看點

sql中添加唯一索引(非主鍵)

if OBJECT_ID('tempdb..#tem') is not null drop table #tem

create table #tem (aa nvarchar(20))

alter table #tem add constraint UQ_aa unique (aa)

insert into #tem(aa) values ('1')

insert into #tem(aa) values (' ')