linux5.6以下版本的不兼容问题
之前一直用的都是mysql5.6版本,最近突然使用到了mysql5.1版本,于是在导入数据的时候便出现了很多由于版本不兼容的问题。
1.mysql5.1没有datetime类型,所以对于时间类型,只能使用timestamp
例:
`FRecordTime` datetime DEFAULT CURRENT_TIMESTAMP
需要改为
`FRecordTime` timestamp DEFAULT CURRENT_TIMESTAMP,
2.mysql5.6版本以下不允许一个表有两个current_timestamp
例:
当你创建该表时:
CREATE TABLE `example` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastUpdated` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
会出错,错误信息为:
ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause.
意思是只能有一个带CURRENT_TIMESTAMP的timestamp列存在。其实在mysql5.5中存在这么一句话:
One TIMESTAMP column in a table can have the current timestamp as the default value for initializing the column,
as the auto-update value, or both. It is not possible to have the current timestamp be the
default value for one column and the auto-update value for another column.
而在mysql5.6中则进行了修改:
Previously, at most one TIMESTAMP column per table could be automatically initialized or updated to the current date and time.
This restriction has been lifted. Any TIMESTAMP column definition can have any combination
of DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP clauses.
In addition, these clauses now can be used with DATETIME column definitions.
For more information, see Automatic Initialization and Updating for TIMESTAMP and DATETIME.
即允许了这种情况出现。
解决方法:
可以用触发器实现上述表的创建:
CREATE TABLE `example` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastUpdated` DATETIME NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
DROP TRIGGER IF EXISTS `update_example_trigger`;
DELIMITER //
CREATE TRIGGER `update_example_trigger` BEFORE UPDATE ON `example`
FOR EACH ROW SET NEW.`lastUpdated` = NOW()
//
DELIMITER ;
3.mysql5.1的limit语句后面只允许跟常量不允许是变量
在存储过程的中,mysql5.6允许limit后面直接跟着输入参数,但是mysql5.1只允许limit后面跟着常量。
解决方法:
1)采用动态的方式
PREPARE stmt1 FROM 'select * from users LIMIT ?,?';
SET @a = ino;
SET @b = pagecount
EXECUTE stmt1 USING @a, @b;
2)将变量事先转换为字符:
set @dd=conact('select * from users LIMIT',ino,pagecount)
PREPARE stmt1 FROM dd
EXECUTE stmt1
linux5.6以下版本的不兼容问题的更多相关文章
- Python爬虫教程-27-Selenium Chrome版本与chromedriver兼容版本对照表
我们使用Selenium+Chrome时,版本不一样, 会导致 chromedriver 停止运行 chromedriver 所有版本下载链接:http://npm.taobao.org/mirror ...
- ie低版本内核事件兼容问题(事件绑定,绑定事件自动执行,文档模式问题)
问题情况 搜狗等,兼容模式下,以前前端写的点击事件的代码没有, 后来一看是因为兼容模式为9,导致点击事件失效 解决办法,步骤 1,处理绑定事件兼容问题 ie低版本绑定事件只支持attactevent, ...
- 解决spring-boot 各版本包冲突兼容的方法
思路 在微服务盛行的当下,spring boot 流行程度已经家喻户晓.但同时,随着spring boot 快速迭代,出现了很多版本,比如当前已经推出了2.2.x-SNAPSHOT/ , ...
- 高版本api在低版本中的兼容
直接上例子,看如何避免crash. eg:根据给出路径,获取此路径所在分区的总空间大小. 文档说明:获取文件系统用量情况,在API level 9及其以上的系统,可直接调用File对象的相关方法,以下 ...
- 【转载】pygame安装与两种版本的Python兼容问题
在开始学习游戏编程之前,我们先来安装下pygame和python3.2.5 参考园友: http://www.cnblogs.com/hongten/p/hongten_pygame_install. ...
- css针对(各大浏览器、各版本)调兼容
ie6\ie7\firefox之下各自识别的CSS符号 #1 { color: #333; } /* firefox */ * html #1 { color: #666; } /* IE6 */ * ...
- js检测浏览器版本代码,兼容ie11
原文:http://blog.csdn.net/tenkin/article/details/11640165 <script type="text/javascript"& ...
- 解决ie 低版本的 background-size 兼容问题
在IE不支持这个属性的时候可以通过滤镜来实现这样的一个效果. div{background-size: cover;filter:progid:DXImageTransform.Microsoft.A ...
- aapt命令获取apk详细信息(包名、版本号、版本名称、兼容api级别、启动Activity等)
1.安装SDK,使用SDK自带的aapt进行查看.aapt所在位置:D:\SDK\build-tools下,任一一个均可,如D:\SDK\build-tools\19.1.0 2.cmd命令下进入ap ...
随机推荐
- laya的那些坑
游戏运行在chrome里面 听不见声音 游戏运行在chrome里面 听不见声音:其它浏览器可以听见声音开发者模式提示如下: The AudioContext was not allowed to s ...
- h5新增内容
1.新的input type值 email url search tel color range number date month week time datetime datetime-local ...
- RTP RTCP RTSP
1.RTP over UDP和RTP over RTSP有什么区别?2.RTP over RTSP是不是就是RTP over TCP?3.RTP over TCP 打包视频是不是要加4个字节的头,是 ...
- firefox extension教程
https://developer.mozilla.org/zh-CN/docs/Add-ons/Overlay_Extensions/XUL_School/The_Essentials_of_an_ ...
- 昨天办了一张地铁卡,我想到一个app
如果成都开通 扫 二维码 做地铁.地铁是距离收费的,如果我们有一个平台,搜集所有用户的 入站 和出站二维码,然后重新分配,那么每个用户就只用 出 2块钱每次的最低消费了.哈哈............. ...
- JMeter - Perfmon - ServerAgent
−Table of Contents 1 - Installation 2 - Usage and commands 2.1 - PerfMon Metrics Collector Listener ...
- ubuntu如何为获得root权限
在终端中输入:sudo passwd rootEnter new UNIX password: (在这输入你的密码)Retype new UNIX password: (确定你输入的密码)passwd ...
- Combobox中禁止鼠标中键滚动list列表
//第1种方法 procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; Mo ...
- FLIR ONE PRO热成像仪
FLIR ONE PRO热成像仪 https://www.chiphell.com/thread-1774218-1-1.html
- tomcat源码 StandardService
在执行StandardServer的initInternal的时候会执行StandardService#init,然后会调到initInternal protected void startInter ...