码迷,mamicode.com
首页 > 数据库 > 详细

MySql 之UUID()

时间:2017-05-25 00:06:28      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:日志   基于   different   guid   使用   not   binlog   return   where   

mysql中做了个定时执行的事件,发现原来起作用,现在不行了。

调用/var/lib/mysql中的错误日志文件,发现一句:

Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.

原来目前用的mysql版本低,UUID函数不支持MySQL 复制的STATEMENT模式。

先改代码吧,保证对低版本的兼容性:

BEGIN
-- UUID函数属于不确定性函数,为此不支持MySQL 复制的STATEMENT模式,但是支持MIXED、ROW二种模式
-- 在复制模式下,需要用到UUID()函数,则一定要使用基于行/混合模式复制方式。
set binlog_format = MIXED;
insert into Users(userName,guid,userpinyin,userpy,uper)
select DISTINCT userName, UUID(), to_pinyin(userName),to_pinyinsx(userName),Domain from t_zhangdan a
where not exists(select 1 from Users where userName=a.userName);
END

 

MySql 之UUID()

标签:日志   基于   different   guid   使用   not   binlog   return   where   

原文地址:http://www.cnblogs.com/dreamfine/p/6901355.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!