-2
CREATE TABLE IF NOT EXISTS `contracts` (
  `contractId` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT,
  `title` varchar(20) CHARACTER SET utf8 NOT NULL,
  `contractText` text CHARACTER SET utf8 NOT NULL,
  `date` datetime NOT NULL,
  `contractState` tinyint(1) NOT NULL COMMENT '1-Nepatvirtinta, 2- patvirtinta, 3-  panaikinta, 4- atmesta',
  PRIMARY KEY (`contractId`),
  UNIQUE KEY `title` (`title`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_lithuanian_ci AUTO_INCREMENT=15 ;



INSERT INTO `contracts` (`contractId`, `username`, `title`, `contractText`, `date`,   `contractState`) VALUES


CREATE TABLE IF NOT EXISTS `users` (
  `username` varchar(32) CHARACTER SET utf8 NOT NULL,
  `password` varchar(32) CHARACTER SET utf8 NOT NULL,
  `email` varchar(20) CHARACTER SET utf8 NOT NULL,
  `usergroup` tinyint(1) NOT NULL COMMENT,
  `name` varchar(32) CHARACTER SET utf8 NOT NULL,
  `lastname` varchar(32) CHARACTER SET utf8 NOT NULL,
  `state` tinyint(4) NOT NULL COMMENT,
 PRIMARY KEY (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_lithuanian_ci;

在 SQL 服务器上运行此查询时,我收到以下错误:

MySQL 说:文档

#1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 13 行的 ' titlevarchar(20) CHARACTER SET utf8 NOT NULL, contractTexttext CHAR'附近使用正确的语法

为什么会出现这种情况?

4

4 回答 4

1

在这一行

      `username` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT 'comment',

为 COMMENT 或 Remove Comment 添加一些评论。下面是工作代码。

 CREATE TABLE IF NOT EXISTS `contracts` (
`contractId` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT 'comment',
`title` varchar(20) CHARACTER SET utf8 NOT NULL,
`contractText` text CHARACTER SET utf8 NOT NULL,
`date` datetime NOT NULL,
`contractState` tinyint(1) NOT NULL COMMENT '1-Nepatvirtinta, 2- patvirtinta, 3-    
 panaikinta, 4- atmesta',
 PRIMARY KEY (`contractId`),
 UNIQUE KEY `title` (`title`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_lithuanian_ci AUTO_INCREMENT=15 ;
于 2013-11-04T07:29:09.240 回答
1

您没有向该username列添加评论。

`username` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT  ,
        add one here---------------------------------------^

或删除COMMENT关键字

于 2013-11-04T07:29:03.680 回答
0

只需修复您的表创建以添加显式注释或删除 COMMENT 关键字(如果不需要)。

尝试将其修改为:

CREATE TABLE IF NOT EXISTS `contracts` (
  `contractId` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT 'add explicit comment her',
  `title` varchar(20) CHARACTER SET utf8 NOT NULL,
  `contractText` text CHARACTER SET utf8 NOT NULL,
  `date` datetime NOT NULL,
  `contractState` tinyint(1) NOT NULL COMMENT '1-Nepatvirtinta, 2- patvirtinta, 3- panaikinta, 4- atmesta',
  PRIMARY KEY (`contractId`),
  UNIQUE KEY `title` (`title`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_lithuanian_ci AUTO_INCREMENT=15 ;
于 2013-11-04T07:29:53.710 回答
0

comment从此行中删除:

`username` varchar(32) CHARACTER SET utf8 NOT NULL , //COMMENT
于 2013-11-04T07:30:40.247 回答