create table [dbo].[Products]( [Id] [int] IDENTITY(1,1) NOT NULL, [ProductName] [nvarchar](max) NULL, [Category] [int] NOT NULL, [ProductsDetail] [int] NOT NULL, constraint [PK__Products__3214EC0753DB1A8D] primary key clustered ( Id asc )with (pad_index = off, statistics_norecompute=off, ignore_dup_key=off,allow_row_locks=on,allow_page_locks =on) on primary ) on primary textimage_on primary go
更新表创建约束
alter table [dbo].[Products] with check add constraint [FK_Products_{ProductsDetails] foreign key([ProductsDetail])
references [dbo].[ProductsDetails] ([PId])