Reputation: 7
I am trying to create a table in mysql database with the following code:
CREATE TABLE `abcd` (
`A` int(11) NOT NULL DEFAULT '0' primary key,
`B` varchar(45) NOT NULL,
`C` datetime,
`D` datetime,
`E` varchar(16),
`F` varchar(16),
`G` int(5) NOT NULL DEFAULT '0',
`H` int(11) NOT NULL DEFAULT '0',
`I` int(20),
`J` int(20),
`K` datetime,
) TYPE=MyISAM ;
I am getting the following 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 ') TYPE=MyISAM' at line 13.
I have also used ENGINE=MyISAM but getting the same error. Can anyone explain where there is syntax error in the code? Thanks in advance!!
Upvotes: 0
Views: 67
Reputation: 1776
You have an unnecessary comma after K datetime
. This is throwing the error mentioned.
Also, use ENGINE=MYISAM
instead of TYPE=MYISAM
.
Here's the query.
CREATE TABLE `abcd` (
`A` int(11) NOT NULL DEFAULT '0' primary key,
`B` varchar(45) NOT NULL,
`C` datetime,
`D` datetime,
`E` varchar(16),
`F` varchar(16),
`G` int(5) NOT NULL DEFAULT '0',
`H` int(11) NOT NULL DEFAULT '0',
`I` int(20),
`J` int(20),
`K` datetime
) ENGINE=MyISAM ;
Upvotes: 1
Reputation: 24970
working off what @Thanos said, it is engine, not type
CREATE TABLE `abcd` (
`A` int(11) NOT NULL DEFAULT '0' primary key,
`B` varchar(45) NOT NULL,
`C` datetime,
`D` datetime,
`E` varchar(16),
`F` varchar(16),
`G` int(5) NOT NULL DEFAULT '0',
`H` int(11) NOT NULL DEFAULT '0',
`I` int(20),
`J` int(20),
`K` datetime
) engine=MyISAM ;
tested
Upvotes: 1
Reputation: 2624
Remove the comma before the parenthesis, like this:
CREATE TABLE `abcd` (
`A` int(11) NOT NULL DEFAULT '0' primary key,
`B` varchar(45) NOT NULL,
`C` datetime,
`D` datetime,
`E` varchar(16),
`F` varchar(16),
`G` int(5) NOT NULL DEFAULT '0',
`H` int(11) NOT NULL DEFAULT '0',
`I` int(20),
`J` int(20),
`K` datetime
) TYPE=MyISAM ;
Upvotes: 0