在使用mysql执行update的时候,若where条件中未使用主键,则会报如下错误,无法执行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 Queries and reconnect.
解决方法:
这是因为MySql运行在safe-updates模式下,修改数据库安全模式,允许在非主键条件下执行update或者delete命令。
执行命令:
SET SQL_SAFE_UPDATES = 0;