在MySQL语法中创建表错误 [英] CREATE TABLE in MySQL syntax error

查看:76
本文介绍了在MySQL语法中创建表错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用数据库将其与我的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

这篇关于在MySQL语法中创建表错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆