TechnoLearnAcademy

TECHNOLEARN

PRIMARY KEY CONSTRAINT

A PRIMARY KEY constraint enforces uniqueness and non-null values for a column in a relational database table.
    • The primary key column cannot have duplicated values.
    • The primary key cannot contain null values.
    • A table can have only one primary key.

Example:

   Objective: In this example, we will be creating a table that has a primary key assigned to an specific column.
                      CREATE TABLE TBL_EMP(
                                                              Ecode varchar(20) Primary key,
                                                              Name varchar(20),
                                                              Emailaddress varchar(20),
                                                              Department varchar(20),
                                                              Salary int
                                                                              );
Scroll to Top