TechnoLearnAcademy

TECHNOLEARN

SQL IDENTITY CONSTRAINT

The IDENTITY Constraint is used to automatically generate unique values for a column when new rows are inserted into a table.

Example:

   Objective: In this example, we will assign Identity constraint to the Ecode column.
                      CREATE TABLE TBL_EMP(
                                                              Ecode Identity(1,1) Int Primary key,
                                                              Name varchar(20),
                                                              Emailaddress varchar(20),
                                                              Department varchar(20) NOT NULL,
                                                              Salary int
                                                                              );
Scroll to Top