简体   繁体   中英

unable to create mySQL table

here i'm going to create basic mysql table but have a problem.

Error is : #1064 - 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 'IDENTITY PRIMARY KEY NOT NULL, NAME varchar(100) )' at line 3

CREATE TABLE `AB_CATEGORY`
(
ID integer IDENTITY PRIMARY KEY NOT NULL,
NAME varchar(100)
);

Just remove the IDENTITY keyword-

CREATE TABLE `AB_CATEGORY`
(
   ID integer PRIMARY KEY NOT NULL,
   NAME varchar(100)
);

In your query to create a table, you are using MS SQL version of auto increment which is IDENTITY . Use this query instead:

CREATE TABLE `AB_CATEGORY`
(
ID int PRIMARY KEY NOT NULL AUTO_INCREMENT,
NAME varchar(100)
);

Check out auto incrementing documentation here

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