This example is taken from w3schools.
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName)
)
My understanding is that both columns together (P_Id
and LastName
) represent a primary key for the table Persons
. Is this correct?
- Why would someone want to use multiple columns as primary keys instead of a single column?
- How many columns can be used together as a primary key in a given table?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…