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)
)
The above example is taken from w3schools.
From the above example, my understanding is that both P_Id, LastName together represents a Primary Key for the table Persons, correct ?
Another question is why would some one want to use multiple columns as Primary keys instead of a single column ? How many such columns can be used in together as Primary key in a given table ?
Thanks
Balaji S