Reputation: 1074
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 :
date
VARCHAR(255) NOT NULL , PRIMARY KEY (Id
(5))) ENGINE =' at line 1I don't really understand what the error mean ? any Idea ?
Upvotes: 0
Views: 2508
Reputation: 1771
"double" doesn't take a length argument, just like Gordon Linoff said above.
I got almost exactly the same problem.
Then I got rid of the length for double, and everything is fine now.
Upvotes: 0
Reputation: 4277
You'll want to assign the decimal for the double:
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,2) NOT NULL,
`date` VARCHAR (255) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE = MEMORY;
Upvotes: 1
Reputation: 1269503
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.
Upvotes: 2