我使用dbForge(v6)导出了一个数据库,整个脚本有一个问题:
USE `global-cms-content2`;
CREATE TABLE `global-cms-content2`.umbracorelationtype (
ID int(11) NOT NULL AUTO_INCREMENT,
DUAL bit(1) NOT NULL,
PARENTOBJECTTYPE char(36) NOT NULL,
CHILDOBJECTTYPE char(36) NOT NULL,
NAME varchar(255) NOT NULL,
ALIAS varchar(100) DEFAULT NULL,
PRIMARY KEY (ID)
)
ENGINE = INNODB
AUTO_INCREMENT = 2
AVG_ROW_LENGTH = 16384
CHARACTER SET utf8
COLLATE utf8_general_ci;
错误是:
1 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 'DUAL bit(1) NOT NULL,
PARENTOBJECTTYPE char(36) NOT NULL,
CHILDOBJECTTYPE ' at line 3 SQL2.sql 2 1
即使我使用编辑器手动创建表,也会发生相同的错误。
为什么MySQL不使用自己的脚本? 有什么想法吗?
更新
这样做了!
USE `global-cms-content3`;
CREATE TABLE `global-cms-content3`.umbracorelationtype (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`DUAL` bit(1) NOT NULL,
`PARENTOBJECTTYPE` char(36) NOT NULL,
`CHILDOBJECTTYPE` char(36) NOT NULL,
`NAME` varchar(255) NOT NULL,
`ALIAS` varchar(100) DEFAULT NULL,
PRIMARY KEY (ID)
)
ENGINE = INNODB
AUTO_INCREMENT = 2
AVG_ROW_LENGTH = 16384
CHARACTER SET utf8
COLLATE utf8_general_ci;
仍然不确定为什么导出脚本或备份数据库脚本不会处理保留的关键字......无论如何
答案 0 :(得分:3)
DUAL这个词是一个关键词。见Keyword list。 试着引用下面这个词:
CREATE TABLE `global-cms-content2`.umbracorelationtype (
ID int(11) NOT NULL AUTO_INCREMENT,
`DUAL` bit(1) NOT NULL,
PARENTOBJECTTYPE char(36) NOT NULL,
CHILDOBJECTTYPE char(36) NOT NULL,
NAME varchar(255) NOT NULL,
ALIAS varchar(100) DEFAULT NULL,
PRIMARY KEY (ID)
)