在MySQL中执行UPDATE语句,报如下错误:
复制
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.032 sec
这是因为MySql运行在safe-updates模式下,该模式会导致非主键条件下无法执行update或者delete命令。而只允许基于主键进行更新。
解决方法一:
执行如下命令,修改数据库模式:
复制
SET SQL_SAFE_UPDATES = 0;
解决方法二:
在UPDATE的语句中,WHERE条件后使用主键字段进行限定更新的范围。