show variables like 'sql_safe_updates';
set sql_safe_updates = 0;
show variables like 'sql_safe_updates';

mysql的SQL使用记录

 

 

二、备份数据

create table t_book_lzg_01 select * from spring5.t_book  where user_id >= 320016832 and user_id <= 320016868;

注意,这种语句存在许多问题:

  1. 您不为新表创建索引
  2. 您在一个事务中混合了事务性和非事务性语句时,与任何DDL一样,它将提交当前和未完成的事务
  3. 使用基于GTID的复制时不支持 CREATE TABLE ... SELECT
  4. 在语句完成之前,元数据锁不会释放(查询的t_book表的行数据)
  5. 不能将原表中的default value也一同迁移过来

三、批量替换数据表中的数据

update spring5.t_book  set user_name = replace (user_name, "我", "你") , user_name  = replace (user_name, "不", "可以")
where  user_id >= 320016832 and user_id <= 320016868;

注意:不支持通过其他表的数据进行指定更新

如:

... where  user_id in (1,2,3,4,5);
... where  user_id in (select id from b);

 

四、通过备份表进行数据恢复:

update spring5.t_book w inner join t_book_lzg_01 e on w.user_id = e.user_id set w.user_name = e.user_name;

 

相关文章: