Using Auto Increment

suggest change

Many databases allow to make the primary key value automatically increment when a new key is added. This ensures that every key is different.

MySQL

CREATE TABLE Employees (
    Id int NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (Id)
);

PostgreSQL

CREATE TABLE Employees (
    Id SERIAL PRIMARY KEY
);

SQL Server

CREATE TABLE Employees (
    Id int NOT NULL IDENTITY,
    PRIMARY KEY (Id)
);

SQLite

CREATE TABLE Employees (
    Id INTEGER PRIMARY KEY    
);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents