1、
Create table ParentChild
(
ParentID int not null,
ChildID int not null
)
ALTER TABLE ParentChild ADD PRIMARY KEY(ParentID , ChildID)
2、
Create table ParentChild
(
ParentID int NOT NULL ,
ChildID int NOT NULL ,
CONSTRAINT PK_ParentChild PRIMARY KEY CLUSTERED(ParentID,ChildID)
)
3、
Create table ParentChild
(
ParentID int not null,
ChildID int not null PRIMARY KEY(ParentID , ChildID)
)
Create table ParentChild
(
ParentID int not null,
ChildID int not null
)
ALTER TABLE ParentChild ADD PRIMARY KEY(ParentID , ChildID)
2、
Create table ParentChild
(
ParentID int NOT NULL ,
ChildID int NOT NULL ,
CONSTRAINT PK_ParentChild PRIMARY KEY CLUSTERED(ParentID,ChildID)
)
3、
Create table ParentChild
(
ParentID int not null,
ChildID int not null PRIMARY KEY(ParentID , ChildID)
)
本文介绍了三种不同的方法来创建一个名为ParentChild的表,并为该表定义复合主键。这些方法展示了如何使用SQL语句来确保ParentID和ChildID字段的组合唯一性。
1196

被折叠的 条评论
为什么被折叠?



