我刚刚使用phpmyadmin导出了一个奇异表的CREATE sql。这是结果:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`register_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`account_type` int(11) NOT NULL,
`active` int(11) NOT NULL,
`email` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`login` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(200) COLLATE utf8_unicode_ci NOT NULL
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
但是当我在phpmyadmin上运行此代码时,我收到此错误:
#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 '(`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREME' at line 14
我尝试了很多方法,但我的技能还不够。
答案 0 :(得分:4)
您忘记在PRIMARY KEY (id)
`name` varchar(200) COLLATE utf8_unicode_ci NOT NULL, -- <== this
PRIMARY KEY (`id`)
添加逗号即可,see this fiddle (click link)