Add Unique constaint to table creation : Unique « Constraints « SQL Server / T-SQL






Add Unique constaint to table creation

17>
18> -- Add Unique constaint to table creation
19> CREATE TABLE projects (project_no   CHAR(4)  DEFAULT 'p1',
20>                        project_name CHAR(15) NOT NULL,
21>                        budget       FLOAT    NULL
22>                        CONSTRAINT   unique_no UNIQUE (project_no))
23> GO
1>
2> drop table projects
3> GO
1>

           
       








Related examples in the same category

1.A unique constraint
2.Adding a UNIQUE Constraint to an Existing Table