Auto Increment allows a unique number which is automatically generated every time a new record is inserted in the table. SQL Auto Increment is mainly used in Primary Field.
Or, we can say that when a new record is inserted in database table then the identity value increased automatically for that record. Often it created as in primary key that I would like to created automatically when a new record is inserted. In other word Identity is called as auto-increment.
There is database table is created with Identity Constraint in primary as like below,
create table Student(
stuID int IDENTITY(101,1) primary key,
stuRollNO int,
stuName varchar(255),
stuCourse varchar(255),
stuAge int );
Now, records is inserted in the above created table,
insert into Student
Values(123,'Ravi Vishwakarma','MCA',23),
(124,'Shriyam','Marketing',22);
It you observe that in above SQL statement in which record is insert in database table column ‘stuID’ is not inserted through command, it is automatically generated. So stuID in automatically generated when I insert a new record into that table because ‘stuID’ is defined as Identity.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
SQL Identity:
Auto Increment allows a unique number which is automatically generated every time a new record is inserted in the table. SQL Auto Increment is mainly used in Primary Field.
Or, we can say that when a new record is inserted in database table then the identity value increased automatically for that record. Often it created as in primary key that I would like to created automatically when a new record is inserted. In other word Identity is called as auto-increment.
Syntax-
Example:
There is database table is created with Identity Constraint in primary as like below,
Now, records is inserted in the above created table,
It you observe that in above SQL statement in which record is insert in database table column ‘stuID’ is not inserted through command, it is automatically generated. So stuID in automatically generated when I insert a new record into that table because ‘stuID’ is defined as Identity.