Creating a UNIQUE Constraints when creating a table : Unique « Constraints « SQL Server / T-SQL Tutorial






5>
6>    CREATE TABLE Shippers
7>    (
8>       ShipperID     int    IDENTITY    NOT NULL
9>          PRIMARY KEY,
10>       ShipperName   varchar(30)        NOT NULL,
11>       Address       varchar(30)        NOT NULL,
12>       City          varchar(25)        NOT NULL,
13>       State         char(2)            NOT NULL,
14>       Zip           varchar(10)        NOT NULL,
15>       PhoneNo       varchar(14)        NOT NULL
16>          UNIQUE
17>    )
18>    GO
1>
2>    drop table Shippers;
3>    GO








7.10.Unique
7.10.1.Adding a UNIQUE Constraint to an Existing Table
7.10.2.Unique constraints will also allow one NULL, whereas primary keys will not.
7.10.3.Unique Constraint: Enforce uniqueness on a column which is not the column used to primarily identify each row.
7.10.4.Unique constraints can be created when initially creating the table or added after.
7.10.5.Unique constraint
7.10.6.Creating a UNIQUE Constraints when creating a table
7.10.7.Creating UNIQUE Constraints on Existing Tables