ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
2013-01-15 16:26
411 查看
今天,写了一个创建数据库表的SQL语句如下:
CREATE TABLE Release(
ReleaseID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(128) NOT NULL,
Version VARCHAR(128) NOT NULL,
SubVersion VARCHAR(128) NOT NULL,
ActiveStatus int(1) default 1 NOT NULL,
ProductID INTEGER NOT NULL REFERENCES product(ProductID),
CreateTime TIMESTAMP NOT NULL,
UpdateTime TIMESTAMP NOT NULL
);
总是报错如下:
ERROR 1064 (42000): 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 'relea
se(
ReleaseID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(128' at line 1
查了MySQL的手册,最后发现是一个简单的原因造成的,这个简单的原因就是release这个单词是一个保留字,不能出现在sql语句中。
于是修改如下:
CREATE TABLE TestRelease(
ReleaseID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(128) NOT NULL,
Version VARCHAR(128) NOT NULL,
SubVersion VARCHAR(128) NOT NULL,
ActiveStatus int(1) default 1 NOT NULL,
ProductID INTEGER NOT NULL REFERENCES product(ProductID),
CreateTime TIMESTAMP NOT NULL,
UpdateTime TIMESTAMP NOT NULL
);
执行结果:
mysql> CREATE TABLE TestRelease(
-> ReleaseID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
-> Name VARCHAR(128) NOT NULL,
-> Version VARCHAR(128) NOT NULL,
-> SubVersion VARCHAR(128) NOT NULL,
-> ActiveStatus int(1) default 1 NOT NULL,
-> ProductID INTEGER NOT NULL REFERENCES product(ProductID),
-> CreateTime TIMESTAMP NOT NULL,
-> UpdateTime TIMESTAMP NOT NULL
-> );
Query OK, 0 rows affected (0.05 sec)
执行成功。
通过这个教训可以得知,其它的保留字段都不可以使用,例如:order table之类的,下次再设计SQL的初期就需要注意到这些问题,可以在开始阶段避免类似问题。
CREATE TABLE Release(
ReleaseID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(128) NOT NULL,
Version VARCHAR(128) NOT NULL,
SubVersion VARCHAR(128) NOT NULL,
ActiveStatus int(1) default 1 NOT NULL,
ProductID INTEGER NOT NULL REFERENCES product(ProductID),
CreateTime TIMESTAMP NOT NULL,
UpdateTime TIMESTAMP NOT NULL
);
总是报错如下:
ERROR 1064 (42000): 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 'relea
se(
ReleaseID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(128' at line 1
查了MySQL的手册,最后发现是一个简单的原因造成的,这个简单的原因就是release这个单词是一个保留字,不能出现在sql语句中。
于是修改如下:
CREATE TABLE TestRelease(
ReleaseID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(128) NOT NULL,
Version VARCHAR(128) NOT NULL,
SubVersion VARCHAR(128) NOT NULL,
ActiveStatus int(1) default 1 NOT NULL,
ProductID INTEGER NOT NULL REFERENCES product(ProductID),
CreateTime TIMESTAMP NOT NULL,
UpdateTime TIMESTAMP NOT NULL
);
执行结果:
mysql> CREATE TABLE TestRelease(
-> ReleaseID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
-> Name VARCHAR(128) NOT NULL,
-> Version VARCHAR(128) NOT NULL,
-> SubVersion VARCHAR(128) NOT NULL,
-> ActiveStatus int(1) default 1 NOT NULL,
-> ProductID INTEGER NOT NULL REFERENCES product(ProductID),
-> CreateTime TIMESTAMP NOT NULL,
-> UpdateTime TIMESTAMP NOT NULL
-> );
Query OK, 0 rows affected (0.05 sec)
执行成功。
通过这个教训可以得知,其它的保留字段都不可以使用,例如:order table之类的,下次再设计SQL的初期就需要注意到这些问题,可以在开始阶段避免类似问题。
相关文章推荐
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- SQL Error: 1064, SQLState: 42000 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ve
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- SQL Error: 1064, SQLState: 42000 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s
- [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s
- [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s
- MySql 执行语句错误 Err] 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
- 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
- Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL se
- 创建存储过程错误(已解决):Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ver
- Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your My
- [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s