mysql 1064 error “sql语法错误” 5.0 与 5.1 中切换

因为需要,在两台机子上跑一个项目。一台机子安装的是mysql 5.1,另外一台是mysql5.0。

当在5.1的测试机上跑通后,拉到了正式的5.0上,一行醒目的 严重:


java.sql.BatchUpdateException: 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 'log(log_id bigint not null auto_increment,user_id bigint not null,action varchar' at line 1


原建表的sql:

create table storage
(
   storage_id            bigint not null,
   log_id                bigint not null,
   content              longblob,
   primary key (storage_id)
);

进入mysql 命令,运行此脚本,正常。修改排版,用String sql 引用:

create table log(log_id bigint not null auto_increment,user_id bigint not null,action varchar(50) not null,time datetime not null,description longtext,primary key(log_id));

将其复制到命令运行,出错!错误同上!郁闷。。

但是相同的语句在mysql5.1中正常运行!

坑爹的发现:

create table log (log_id bigint not null auto_increment,user_id bigint not null,action varchar(50) not null,time datetime not null,description longtext,primary key(log_id));

table 后面的空格!!!在跑!建表成功!

原来mysql5.1 是支持 table(.....)   而 mysql5.0是需要规范的写table (....)

最后,奉劝大家,注意规范,尤其空格!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值