Home  >  Q&A  >  body text

MYSQL (WAMP SERVER): Error 1064 when creating table column with AUTO_INCRMENT=1000?

I have this code: CREATE TABLE Company ( Comp_Code INT(5) NOT NULL AUTO_INCRMENT=1000, Comp_Name VARCHAR(15) NOT NULL, primary key (Comp_Code) ); But when I run it in MYSQL from WAMPServer, I get the error:

Error 1064 (42000): There is an error in your SQL syntax; check the manual for your MySQL server version for the correct syntax to use around '=1000, Comp_Name VARCHAR(15) NOT NULL, Primary key (Comp_Code) )' on line 2

Why does this happen?

P粉681400307P粉681400307203 days ago381

reply all(1)I'll reply

  • P粉569205478

    P粉5692054782024-03-30 16:49:58

    AUTO_INCRMENT is a column option.

    Initial AUTO_INCRMENT=1000 The value is the 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
    

    reply
    0
  • Cancelreply