SQL Server UNIQUE失效
CREATE TABLE dbo.Code_Index ( code SMALLINT IDENTITY(1,1) CONSTRAINT PK_Code_Index_code PRIMARY KEY CLUSTERED (code ASC) WITH(PAD_INDEX=ON,FILLFACTOR=80,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON),
item VARCHAR(20) NOT NULL CONSTRAINT UQ_Code_Index_code UNIQUE NONCLUSTERED (code ASC) WITH(PAD_INDEX=ON,FILLFACTOR=80,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON) )
以上命令建立的表格,依旧能够输入重复数据为什么? 注:输入重复数据是,提示提交数据错误,此数据为只读,表中依旧有两条记录.
CREATE TABLE dbo.Code_Index ( code SMALLINT IDENTITY(1,1) CONSTRAINT PK_Code_Index_code PRIMARY KEY CLUSTERED (code ASC) WITH(PAD_INDEX=ON,FILLFACTOR=80,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON), item VARCHAR(20) NOT NULL CONSTRAINT UQ_Code_Index_code UNIQUE NONCLUSTERED (item ASC) WITH(PAD_INDEX=ON,FILLFACTOR=80,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON) ) INSERT INTO Code_Index(item) VALUES ('a') INSERT INTO Code_Index(item) VALUES ('a') SELECT * FROM Code_Index
CREATE TABLE dbo.Code_Index ( code SMALLINT IDENTITY(1,1) CONSTRAINT PK_Code_Index_code PRIMARY KEY CLUSTERED (code ASC) WITH(PAD_INDEX=ON,FILLFACTOR=80,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON), item VARCHAR(20) NOT NULL CONSTRAINT UQ_Code_Index_code UNIQUE NONCLUSTERED (item ASC) WITH(PAD_INDEX=ON,FILLFACTOR=80,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON) )
|