Home > Net >  MYSQL (WAMP SERVER): Error 1064 when using AUTO_INCREMENT=1000 to create table column?
MYSQL (WAMP SERVER): Error 1064 when using AUTO_INCREMENT=1000 to create table column?

Time:06-28

I have this code: CREATE TABLE Company ( Comp_Code INT(5) NOT NULL AUTO_INCREMENT=1000, Comp_Name VARCHAR(15) NOT NULL, PRIMARY KEY (Comp_Code) ); but when i run it in MYSQL from WAMPServer it gives an error:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=1000, Comp_Name VARCHAR(15) NOT NULL, PRIMARY KEY (Comp_Code) )' at line 2

Why is this happening? I can't seem to find any solution to this particular issuer.

CodePudding user response:

AUTO_INCREMENT is column option.

Initial AUTO_INCREMENT=1000 value is table option.

CREATE TABLE Company ( 
    Comp_Code INT(5) NOT NULL AUTO_INCREMENT,  -- specify that the column is AI
    Comp_Name VARCHAR(15) NOT NULL, 
    PRIMARY KEY (Comp_Code) 
) AUTO_INCREMENT=1000;                         -- specify initial AI value
  • Related