SQL AUTO INCREMENT

The SQL AUTO INCREMENT field is used to create a numerical PRIMARY KEY value for each additional row of data in a column. By default, AUTO_INCREMENT value will start with "1".

AUTO INCREMENT Syntax

CREATE TABLE table_name (
  column1 datatype   NOT NULL AUTO_INCREMENT,
  colum2 tadatype   NOT NULL,
  ...,
  ...,
  PRIMARY KEY (column1)
);

AUTO INCREMENT Conditions

  • AUTO INCREMENT allows a unique number to be generated automatically when the new record is insert into a table means no need to give a numbering.
  • The starting value for AUTO INCREMENT is "1" by default and when insert a new records then this field will increment by 1 for each new record.
  • We can change the AUTO INCREMENT start sequence use below SQL commond.
ALTER TABLE table_name AUTO_INCREMENT=10;

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

© 2023 GDATAMART.COM (All Rights Reserved)