创建表和创建表约束

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])

 

posted @ 2013-04-18 10:35  程序员--靖  阅读(195)  评论(0编辑  收藏  举报