TechnoLearnAcademy

TECHNOLEARN

SQL ALTER Statement ADD PRIMARY KEY

The ALTER Statement is used to add a new constraint to an existing table.
Add Primary Key Constraint

Syntax:      

                  ALTER TABLE  table_name 
                  ADD CONSTRAINT ConstraintName 
                  Primary Key (column_name);

Example:

   Objective: In this example, we will add a primary key constraint to an existing table emp.
                      ALTER TABLE Tbl_Emp
                      ADD CONSTRAINT pk_const
                      PRIMARY KEY (ecode);
Scroll to Top