1

我刚刚使用 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

我尝试了很多方法,但我的技能还不够。

4

1 回答 1

4

你之前忘了加逗号PRIMARY KEY (id)

`name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,   -- <== this
 PRIMARY KEY (`id`)

添加逗号,它会工作,看到这个小提琴(点击链接)

于 2012-10-09T01:42:00.493 回答