啥数据库呢
--------
- 创建表时添加唯一约束
CREATE TABLE Employees (
EmployeeID INT NOT NULL,
EmployeeName NVARCHAR(50) NOT NULL,
Email NVARCHAR(100),
CONSTRAINT UC_Employees_Email UNIQUE (Email) -- 这里的UC_Employees_Email是约束名,Email是需要唯一的字段
);
-- 向已存在的表添加唯一约束
ALTER TABLE Employees
ADD CONSTRAINT UC_Employees_EmployeeName UNIQUE (EmployeeName); -- 为EmployeeName字段添加唯一约束