mysql update時報錯You are using safe update mode


在使用mysql執行update的時候,如果不是用主鍵當where語句,會報如下錯誤,使用主鍵用於where語句中正常。

update test.t_bids set product_id=1+floor(rand()*7) 

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.000 sec

 

這是因為MySql運行在safe-updates模式下,該模式會導致非主鍵條件下無法執行update或者delete命令,

執行命令SET SQL_SAFE_UPDATES = 0;修改下數據庫模式

如果想要提高數據庫安全等級,可以在恢復回原有的設置,執行命令:

SET SQL_SAFE_UPDATES = 1;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM