SQL Contraints in CREATE TABLE statement
CREATE TABLE [dbo].[Table1]([Id] [int] NOT NULL,[ParentId] [int] NOT NULL,[Name] [datetime] NULL,[Date] [datetime] NULLCONSTRAINT [DF_Table1_Date] DEFAULT getdate(), --defaultCONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED -- primary key([Id] ASC),CONSTRAINT [UQ_Table1_Name] UNIQUE NONCLUSTERED --unique key([Name] ASC),CONSTRAINT [FK_Table1_Table2_ParentId] FOREIGN KEY --foreign key([ParentId]) REFERENCES [Table2]([Id]))
Comments
Post a Comment