wuno
wuno

Reputation: 9865

Troubleshooting MySQL Syntax Errors

I am trying to create a new table which has always been pretty easy in the past. This time I am trying to increase the quality of the way I do things by researching the collation I use as the default for my table. After reading a bit I decided utf8mb4_unicode_ci was the way to go.

At this point I create a table with 11 rows. Everytime I try and submit it tells me,

  #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 
') NOT NULL , `password` INT(10000) NOT NULL , `hash` VARCHAR(10000) NOT 
NULL ,' at line 1 

I have never had auto generated sql give me an error before. So, I think this has to do with the coalition I chose. Also it appears to have a problem close to my double. Which leads me to believe I can't use the collation I am using with a Double?

Any help would be appreciated.

Thank you,

    CREATE TABLE `skel`.`accounts` ( `id` INT(11) NOT NULL AUTO_INCREMENT 
, `username` VARCHAR(255) NOT NULL , `email` VARCHAR(255) NOT NULL , 
`first` VARCHAR(255) NOT NULL , `last` VARCHAR(255) NOT NULL , `phone` 
VARCHAR(50) NOT NULL , `address` VARCHAR(255) NOT NULL , `rate` 
DOUBLE(20) NOT NULL , `password` VARCHAR(40) NOT NULL , `hash` 
VARCHAR(40) NOT NULL , `confirmed` VARCHAR(5) NOT NULL , PRIMARY KEY 
(`id`)) ENGINE = InnoDB;

Upvotes: 0

Views: 43

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269513

DOUBLE(20) is not a valid data type. In MySQL, double requires both scale and precision to be specified (if either is). This is explained in the documentation.

So, specifying something like DOUBLE(20, 5) should be acceptable.

Also, INT(10000) doesn't really make sense. You don't need the length specifier, but perhaps you intend INT(5) (5 digits of precision). Or perhaps you should use DECIMAL() for the column.

Upvotes: 4

Related Questions