CREATE TABLE in MySQL syntax error

前端 未结 2 2014
清歌不尽
清歌不尽 2021-01-29 07:30

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 - You ha

2条回答
  •  爱一瞬间的悲伤
    2021-01-29 07:58

    DOUBLE requires precision too ( I gave DOUBLE(20,2) - change it as needed).

    Plus there was a stray space at the end of serial number column name.

    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,2) NOT NULL ,
    `Phone` DOUBLE( 20 ,2) NOT NULL ,
    `Id` INT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    UNIQUE (
    `serial number` 
    )
    ) 
    

    Also, it's better to use DECIMAL instead of DOUBLE as the doubles can't be represented exactly and creates problem while doing comparisons.

提交回复
热议问题