[英]Getting #1064 error for below query?
CREATE TABLE IF NOT EXISTS `pset7`.`portfolio`(
`id` int(10) unsigned NOT NULL,
`symbol` varchar(12) NOT NULL,
`shares` double(50) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB;
This is the error: 这是错误:
ERROR : #1064 - You have an error in your SQL syntax;
错误:#1064-您的SQL语法有错误; check the manual that corresponds >to your MySQL server version for the right syntax to use near ') NOT NULL, PRIMARY KEY >(
id
) )ENGINE=InnoDB AUTO_INCREMENT=8' at line 1检查与您的MySQL服务器版本相对应的手册以在')NOT NULL,PRIMARY KEY>(
id
)ENGINE = InnoDB AUTO_INCREMENT = 8'附近使用正确的语法
I don't get what syntax error is, I checked on SQL corrector? 我没有得到什么语法错误,我检查了SQL校正器?
MySQL version - 5.5.35-0ubuntu0.13.10.2 MySQL版本-5.5.35-0ubuntu0.13.10.2
DOULE
needs two arguments DOULE
需要两个参数
`shares` DOUBLE(M,D) NOT NULL
D is the number of digits that may be after the decimal point and M is the total number of digits. D是小数点后的位数,M是位数的总数。 For more info check this out.
有关更多信息,请查看此 。
Ofcourse you could also use this 当然你也可以用这个
`shares` DOUBLE NOT NULL
indicating to the sql engine to take the default values. 指示sql引擎采用默认值。
MySQL permits a nonstandard syntax:
FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D)
. MySQL permits a nonstandard syntax:
FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D)
。 Here, “ (M,D)
” means than values can be stored with up to M digits in total, of which D digits may be after the decimal point. 在此,“
(M,D)
”表示总共可以存储多达M位的值,其中D位可以在小数点后。 For example, a column defined as FLOAT(7,4)
will look like -999.9999
when displayed. 例如,显示为
FLOAT(7,4)
的列看起来像-999.9999
。 MySQL
performs rounding when storing values, so if you insert 999.00009
into a FLOAT(7,4)
column, the approximate result is 999.0001 MySQL
在存储值时执行四舍五入,因此,如果将999.00009
插入FLOAT(7,4)
列,则近似结果为999.0001
So try with 所以尝试
CREATE TABLE `portfolio` (
`id` int(10) NOT NULL,
`symbol` varchar(12) DEFAULT NULL,
`shares` double(10,5) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Refer: http://dev.mysql.com/doc/refman/5.6/en/floating-point-types.html 参考: http : //dev.mysql.com/doc/refman/5.6/en/floating-point-types.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.