Reputation: 175
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; 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
I don't get what syntax error is, I checked on SQL corrector?
MySQL version - 5.5.35-0ubuntu0.13.10.2
Upvotes: 0
Views: 135
Reputation: 5034
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. For example, a column defined as FLOAT(7,4)
will look like -999.9999
when displayed. MySQL
performs rounding when storing values, so if you insert 999.00009
into a FLOAT(7,4)
column, the approximate result is 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
Upvotes: 0
Reputation: 1277
DOULE
needs two arguments
`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. 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.
Upvotes: 1