在 MySQL 语法错误中创建表
我正在尝试使用 db 将它与我的 java 项目链接我正在使用 wampsarver 创建数据库.我该怎么做才能解决这个问题.
i am trying to use the db to link it with my java project and i am using wampsarver to create the db. what should i do to fix this please .
1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册以了解要使用的正确语法Near ') NOT NULL , Phone
DOUBLE( 20 ) NOT NULL , Id
INT( 20 ) NOT第 6 行的 NULL AUTO_INCR'
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 ,
Phone
DOUBLE( 20 ) NOT NULL ,Id
INT( 20 ) NOT NULL AUTO_INCR' at line 6
CREATE TABLE `Laptop` (
`serial number ` INT( 20 ) NOT NULL ,
`Device Model` VARCHAR( 20 ) NOT NULL ,
`Device Manufacturer` VARCHAR( 20 ) NOT NULL ,
`Device Color` VARCHAR( 20 ) NOT NULL ,
`Screen size` DOUBLE( 20 ) NOT NULL ,
`Phone` DOUBLE( 20 ) NOT NULL ,
`Id` INT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
UNIQUE (
`serial number `
)
) ENGINE = innodb
推荐答案
对于 double,您必须在逗号后添加另一个数字以确保精度.此外,名称后不允许有空格.以下脚本正在运行
For double you have to add another digit after comma for precision.Also No space is allowed after name.the following script is working
CREATE TABLE `Laptop` (
`serial number` INT( 20 ) NOT NULL ,
`Device Model` VARCHAR( 20 ) NOT NULL ,
`Device Manufacturer` VARCHAR( 20 ) NOT NULL ,
`Device Color` VARCHAR( 20 ) NOT NULL ,
`Screen size` DOUBLE( 20,4 ) NOT NULL ,
`Phone` DOUBLE( 20,4 ) NOT NULL ,
`Id` INT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
UNIQUE (
`serial number`
)
) ENGINE = innodb
相关文章