E.g.: CK_Employee_EmployeeId
Default Key Constraints => DF_ParentTable_Column
E.g.: DF_Employee_EmployeeId
Foreign Key Constraints => FK_ParentTable_ChildTable_Column
E.g.: FK_Employee_Job_EmployeeId
Primary Key Constraints => PK_ParentTable_Column
E.g.: PK_Employee_EmployeeId
Unique Key Constraints => IX_ParentTable_Column
E.g.: IX_Employee_Email
CREATE TABLE SYNTAX
CREATE TABLE employee (
EmployeeId INT NOT NULL IDENTITY(1, 1),
FirstName VARCHAR(255),
LastName VARCHAR(255),
Email VARCHAR(255) CONSTRAINT IX_Employee_Email UNIQUE
)
ALTER TABLE SYNTAX
ALTER TABLE employee
ADD CONSTRAINT IX_Employee_Email UNIQUE(Email)
For more info on constraints and constraint naming please refer to the following links:
http://msdn.microsoft.com/en-us/library/ms174979.aspx
http://blog.sqlauthority.com/2007/02/05/sql-server-primary-key-constraints-and-unique-key-constraints/
http://msdn.microsoft.com/en-us/library/ms177420.aspx
EmployeeId INT NOT NULL IDENTITY(1, 1),
FirstName VARCHAR(255),
LastName VARCHAR(255),
Email VARCHAR(255) CONSTRAINT IX_Employee_Email UNIQUE
)
ALTER TABLE SYNTAX
ALTER TABLE employee
ADD CONSTRAINT IX_Employee_Email UNIQUE(Email)
For more info on constraints and constraint naming please refer to the following links:
http://msdn.microsoft.com/en-us/library/ms174979.aspx
http://blog.sqlauthority.com/2007/02/05/sql-server-primary-key-constraints-and-unique-key-constraints/
http://msdn.microsoft.com/en-us/library/ms177420.aspx