Search code examples
mysqlsqlddlcreate-table

ERROR 1064 (42000) in Create table statement in MYSQL


The below create table statement is giving an error but everything seams OK.

 explain create table inventory(`id` int primary key, 
         name varchar(30), price float, category varchar(25)); 

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 'create table inventory(id int primary key, name varchar(30), price float, cate' at line 1


Solution

  • explain is used to get an execution plan of a select query (or the structure of an existing table, although it's more common to use describe for that). You cannot apply it to a create table statement. Just remove the explain keyword and you should be fine.