Mysql 5.7,默認執行 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.
原因:
默認的安全策略,使得更新時,如果不依靠主鍵列進行查詢時將被提示並失敗。
解決方式:
SET SQL_SAFE_UPDATES = 0;
關閉掉該方式
修改如下:
SET SQL_SAFE_UPDATES = 0;
UPDATE `column` SET `column` = 新值 WHERE 非主鍵列條件;
SET SQL_SAFE_UPDATES = 1;