Account
Categories

Primary Key


A Primary Key is a column or a combination of columns in a table whose values uniquely identify each record in that table.

For example, suppose the 'student' table contains three columns: Roll ID, Name, and Age, with three rows.

The Roll ID field is the Primary Key because it uniquely identifies each student or record, as every Roll ID is unique.

Only one field can become the Primary Key, such as Roll ID. A Primary Key cannot have NULL values.

It is also important to note that each table can have only one Primary Key.

Syntax:

  CREATE TABLE table_name (
    column_name data_type PRIMARY KEY
);