PRIMARY KEY constraint is used to ensure that all values in a column are unique and cannot contain NULL values. The
PRIMARY KEY constraint forces the column to always accept a UNIQUE value without NULL. In MySQL, you can have only one
PRIMARY KEY constraints on each table. The
PRIMARY KEY constraint can be create on single column or group of multiple columns.
PRIMARY KEYon "custId" column when the "tblCustomer" table is created:
In the above example, we are creating new table called "tblCustomer" using
PRIMARY KEY constraint. The
PRIMARY KEY constraint enforces column "custId" to always accept UNIQUE value without NULL.
You can use MySQL Command Line Client to enforces column "custId" to always accept UNIQUE value without NULL.
PRIMARY KEYon existing table:
PRIMARY KEYconstraint from "tblCustomer" table: