MySQL常见错误 -- update忘加where条件误操作恢复(模拟Oracle闪回功能)
开启binlog,且binlog-format=row
新建一个表
[sql]CREATE TABLE student
(id
int(10) unsigned NOT NULL AUTO_INCREMENT,name
varchar(10) NOT NULL DEFAULT '', class
int(10), score
varchar(10) NOT NULL DEFAULT '', PRIMARY KEY (id
));[/sql]
插入测试数据:
insert into student(name,class,score) values('a',1,56),('b',1,61),('c',2,78),('d',2,45),('e',3,76),('f',3,89),('g',4,43),('h',4,90);
模拟update忘加where条件
update student set score='failure';
mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS bin-log.000039 | grep -B 15 'failure'