By 25/02/2016 9 Comments

What Is AUTO INCREMENT Field In SQL?

  • SQL AUTO INCREMENT is a feature which enables a table column to accept unique values each time when a new record/row to be inserted in it.

OR

  • SQL AUTO INCREMENT generates a unique number each time automatically for a column when a new row/record is inserted.
  • SQL AUTO INCREMENT has value 1 by default and it increased by 1 value each time automatically.
  • In most cases AUTO INCREMENT is applied on a PRIMARY KEY field/column.

Example: MySQL

CREATE TABLE country
(
country_id BIGINT(11) AUTO_INCREMENT,
country_name VARCHAR(200),
country_location VARCHAR(200),
country_zipcode INT(60),
PRIMARY KEY (country_id)
);

Example: SQL Server

CREATE TABLE country
(
country_id int IDENTITY(1,1) PRIMARY KEY,
country_name VARCHAR(200),
country_location VARCHAR(200),
country_zipcode int
);


Note:

  • In above examples AUTO INCREMENT is applied on PRIMARY KEY column (country_id ) in table (country).






Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .