MySql 之UUID()

mysql中作了個定時執行的事件,發現原來起做用,如今不行了。mysql

調用/var/lib/mysql中的錯誤日誌文件,發現一句:sql

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模式。ui

先改代碼吧,保證對低版本的兼容性:日誌

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);
ENDorm

相關文章
相關標籤/搜索