Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.81 KB | None | 0 0
  1. -- Creating table 'LotteryUser'
  2. CREATE TABLE [dbo].[LotteryUser] (
  3.     [Id] bigint IDENTITY(1,1) NOT NULL,
  4.     [UserId] bigint NOT NULL,
  5.     [TenantId] bigint NOT NULL,
  6.     [ContentId] bigint  NOT NULL,
  7.     [Uid] nvarchar(36)  NOT NULL,
  8.     [IsWinner] bit NOT NULL DEFAULT ((0)),
  9.     [Created] datetime  NOT NULL DEFAULT (getdate()),
  10.     [ContentType] nvarchar(255)  NOT NULL DEFAULT (N'Lottery')
  11. );
  12. GO
  13.  
  14. -- Creating primary key on [Id] in table 'LotteryUser'
  15. ALTER TABLE [dbo].[LotteryUser]
  16. ADD CONSTRAINT [PK_LotteryUser]
  17.     PRIMARY KEY CLUSTERED ([Id] ASC);
  18. GO
  19.  
  20. -- Creating foreign key on [ContentId] in table 'LotteryUser'
  21. ALTER TABLE [dbo].[LotteryUser]
  22. ADD CONSTRAINT [FK_LotteryUser_Content]
  23.     FOREIGN KEY ([ContentId])
  24.     REFERENCES [dbo].[Content]
  25.         ([Id])
  26.     ON DELETE CASCADE ON UPDATE NO ACTION;
  27. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement