联合主键建立方法

create table Cart
(
   [UserID] uniqueidentifier not null,
   [ProductID] int not null,
   [ProductName] varchar(80) not null,
   [Price] [decimal](10, 2) NOT NULL,
   [ImagePath] [varchar](100) NULL,
   Quantity int not null,
   IsAnonymous bit not null
)

alter table Cart
add constraint [PK_Cart] primary key CLUSTERED([USerID],[ProductID]) on [Primary]

你可能感兴趣的:(联合主键)