服务器版本的MySQL语法错误

时间:2013-12-24 06:49:02

标签: mysql

下面的代码有什么问题,它会返回错误消息“报告的错误是:您的SQL语法中有错误;请查看与您的MySQL服务器版本对应的手册,以便在'{{'附近使用正确的语法{1}} bigint(20)NOT NULL,输入enum('e','c')NOT NULL,user bigint(20)N'在第1行“

有人可以帮忙吗???

eidcid

3 个答案:

答案 0 :(得分:1)

您在AUTO_INCREMENT之后缺少逗号。

$sqla[] = "CREATE TABLE `" . $GLOBALS['TBL_PREFIX'] . "accesscache` (`cacheid` INT NOT NULL AUTO_INCREMENT,  `user` bigint(20) NOT NULL,  type enum('e','c') NOT NULL,  `eidcid` bigint(20) NOT NULL,  `result` enum('nok','readonly','ok') NOT NULL,  `timestamp_last_change` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY `cacheid` (`cacheid`), KEY `user` (`user`),  KEY `type` (`type`),  KEY `eidcid` (`eidcid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Interleave Access cache table';";

答案 1 :(得分:1)

有两个错误,我将在工作脚本上显示 -

CREATE TABLE `accesscache` (
  `cacheid` int NOT NULL AUTO_INCREMENT, -- need ',' after cacheid
  `user` bigint(20) NOT NULL,
  type enum ('e', 'c') NOT NULL,
  `eidcid` bigint(20) NOT NULL,
  `result` enum ('nok', 'readonly', 'ok') NOT NULL,
  `timestamp_last_change` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`cacheid`), -- PK always named as PRIMARY
  KEY `user` (`user`),
  KEY `type` (`type`),
  KEY `eidcid` (`eidcid`)
)
ENGINE = INNODB
DEFAULT charset = utf8
COMMENT = 'Interleave Access cache table'

答案 2 :(得分:0)

尝试此查询。您忘记在,

之后添加AUTOINCREMENT
   $sqla[] = "CREATE TABLE `" . $GLOBALS['TBL_PREFIX'] . "accesscache` (`cacheid` INT NOT NULL AUTO_INCREMENT, `user` bigint(20) NOT NULL,  type enum('e','c') NOT NULL,  `eidcid` bigint(20) NOT NULL,  `result` enum('nok','readonly','ok') NOT NULL,  `timestamp_last_change` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY `cacheid` (`cacheid`), KEY `user` (`user`),  KEY `type` (`type`),  KEY `eidcid` (`eidcid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Interleave Access cache table';";