简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM