SQL AUTO INCREMENT,Mysql AUTO INCREMENT(identity)

Auto increment allows a unique number to be generated automatically when a new record is inserted into a table.

Sql Examples:
CREATE TABLE Student (
    ID int IDENTITY(1,1) PRIMARY KEY,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int
);

Insert Syntax:
INSERT INTO Student (FirstName,LastName,Age)
VALUES ('Peter1','John1',15);

Result:


Mysql Examples:
CREATE TABLE Student (
    ID int NOT NULL AUTO_INCREMENT,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    PRIMARY KEY (ID)
);

Insert Syntax:
INSERT INTO Student (FirstName,LastName,Age)
VALUES ('Peter','John',15);

Result:

Post a Comment

0 Comments