sql语句执行报错
UPDATE `smart_bpp`.`bpp_bill` b SET b.`receivable_date` = '2019-03-15 19:03:03' WHERE b.id IN (SELECT c.id FROM (SELECT a.id FROM bpp_bill a WHERE a.area_id = '10306' AND a.status = '1') c);
报错信息:
Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect. 0.035 sec
原因:
因为是MySQL Workbench的默认的安全设置是不能批量更新表的。当要执行的SQL语句是进行批量更新或者删除的时候就会提示这个错误
解决办法
方法1:
点击mysqlworkbench-[Preferences...],后会弹出对话框“workbench preferences”,在“workbench”左边栏点击“SQL Editor”,会看到最后一行是“Safe Updates……”是打钩的,我们只要缺消打钩即可。
方法2
执行语句前 将安全机制降低, 执行如下语句即可 set sql_safe_updates = 0