I am trying to create a table in phpmyadmin with the following
SQL : CREATE TABLE `umOrder`.`Bill` ( `Id` INT(5) NOT NULL AUTO_INCREMENT , `userID` VARCHAR(255) NOT NULL , `product` VARCHAR(255) NOT NULL , `quantity` INT(3) NOT NULL , `price` DOUBLE(5) NOT NULL , `date` VARCHAR(255) NOT NULL , PRIMARY KEY (`Id`(5)) ) ENGINE = MEMORY;
But keep getting this error :
1064 – You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘) NOT NULL , date
VARCHAR(255) NOT NULL , PRIMARY KEY (Id
(5))) ENGINE =’ at line 1
I don’t really understand what the error mean ? any Idea ?
Advertisement
Answer
The key(id(5))
is suspect. But you have another error as well: double
doesn’t take a length argument.
The following should work:
CREATE TABLE `Bill` ( `Id` INT(5) NOT NULL AUTO_INCREMENT , `userID` VARCHAR(255) NOT NULL , `product` VARCHAR(255) NOT NULL , `quantity` INT(3) NOT NULL , `price` DOUBLE NOT NULL , `date` VARCHAR(255) NOT NULL , PRIMARY KEY (`Id`) ) ENGINE = MEMORY;
Here is a SQL Fiddle.
Note: I don’t think it is helpful to put length arguments after numeric types (other than decimal
/numeric
). You might want to consider removing all of them.