在数据库中创建新表时出错

时间:2013-12-30 17:24:08

标签: mysql

我想将以下表添加到我的数据库中,但是当我执行脚本时出现错误。我想我错过了一些东西:

      CREATE TABLE IF NOT EXISTS `login_users` (
      `hash` text,
      `photo` text,
      `bio` text,
      `facebook_id` text,
      `added_on` timestamp NULL DEFAULT NULL,
      `achievements` text,
      `last_seen` timestamp NULL DEFAULT NULL,
      `website_url` text,
      `facebook_url` text,
      `twitter_url` text,
        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8_general_ci AUTO_INCREMENT=1 ;

错误:

   debug : #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 ') ENGINE=MyISAM DEFAULTCHARSET=utf8_general_ci AUTO_INCREMENT=1' at line 12{"success":false,"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 ') ENGINE=MyISAM DEFAULT CHARSET=utf8_general_ci AUTO_INCREMENT=1' at line 12<\/div>"}

3 个答案:

答案 0 :(得分:1)

您有一个错误的尾随逗号。

`twitter_url` text, <--
) 

答案 1 :(得分:1)

删除最后一个逗号:

 CREATE TABLE IF NOT EXISTS `login_users` (
      `hash` text,
      `photo` text,
      `bio` text,
      `facebook_id` text,
      `added_on` timestamp NULL DEFAULT NULL,
      `achievements` text,
      `last_seen` timestamp NULL DEFAULT NULL,
      `website_url` text,
      `facebook_url` text,
      `twitter_url` text
        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8_general_ci AUTO_INCREMENT=1 ;

答案 2 :(得分:1)

twitter_url

的定义后,您有一个冗余的逗号
 CREATE TABLE IF NOT EXISTS `login_users` (
  `hash` text,
  `photo` text,
  `bio` text,
  `facebook_id` text,
  `added_on` timestamp NULL DEFAULT NULL,
  `achievements` text,
  `last_seen` timestamp NULL DEFAULT NULL,
  `website_url` text,
  `facebook_url` text,
  `twitter_url` text --Extra comma removed here
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8_general_ci AUTO_INCREMENT=1 ;