2014-02-24 59 views
0

希望我今晚的最后一个问题。我搜索了StackOverflow提供的建议答案,但无法找到解决此问题的答案。这里是我的代码:#1064创建用户表时出错

CREATE TABLE `user_accounts` (
    `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT , 
    `email` text , 
    `password` char(32) DEFAULT NULL , 
    `active` tinyint DEFAULT '0' , 
    `groups` text , 
    `activation_key` varchar(32) DEFAULT NULL , 
    `extras` text , 
    `PRIMARY KEY (`id`), 
) DEFAULT CHARSET=utf8; 

这里是我的错误:

#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`),) DEFAULT CHARSET=utf8' at line 9 

线9 PRIMARY KEYid

我这不是正确定义的东西吗?

+0

看起来你已经做了一些问题.. .still在“1点”声望......你真的接受任何答案吗? – Leo

+0

它不会让我对我的最后一个问题,我会再试一次,虽然在第二个 – user3345518

+1

@Leo他只提出了两个问题,都试图滥用Stack Overflow作为在线语法检查服务。 –

回答

3

你必须在最后一个逗号和额外的反引号PRIMARY KEY

CREATE TABLE `user_accounts` (
    `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT , 
    `email` text , 
    `password` char(32) DEFAULT NULL , 
    `active` tinyint DEFAULT '0' , 
    `groups` text , 
    `activation_key` varchar(32) DEFAULT NULL , 
    `extras` text , 
    PRIMARY KEY (`id`) 
) DEFAULT CHARSET=utf8; 

See fiddle demo

-1

前试试这个:

CREATE TABLE `user_accounts` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 
    `email` text, 
    `password` char(32) DEFAULT NULL, 
    `active` tinyint(4) DEFAULT '0', 
    `groups` text, 
    `activation_key` varchar(32) DEFAULT NULL, 
    `extras` text, 
    PRIMARY KEY (`id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8