What is a composite key in SQL?

1.0K    Asked by LeahHarris in Business Analyst , Asked on Nov 3, 2019
Answered by Kaushik Chandra

A composite key is a primary key with numerous columns as in the case of a few tables a single field might not ensure unique and not null values, so a combination of multiple fields is taken as the primary key. This composite key alludes to cases where more than one column is utilized to indicate the primary key of a table.

Example:

CREATE TABLE Orders(

Ordr ID INT,

Ordr NAME nvarchar(30),

OrdrMENU nvarchar(50),

PRIMARY KEY (OrdrNAME, OrdrMENU));



Your Answer

Interviews

Parent Categories