据我所知,有 2 种创建复合 PK 的方法,但不知道区别或哪种方法好:
CREATE TABLE AppUsers
(
Id int NOT NULL,
Username varchar(20) NOT NULL,
LastName varchar(100),
FirstName varchar(100),
PRIMARY KEY (Id, Username)
)
VS
CREATE TABLE AppUsers
(
Id int NOT NULL,
Username varchar(20) NOT NULL,
LastName varchar(100),
FirstName varchar(100),
CONSTRAINT pk_AppUsers PRIMARY KEY (Id, Username)
)