在作數據庫實驗的時候對mysql表進行UPDATE操做時,mysql給了我一個錯誤: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 modemysql
原來mysql有個叫SQL_SAFE_UPDATES的變量。查了很久,所有中文結果都是copy來copy去的,並且也只是簡單給出解決方式。後來找到老外網,上面這麼說:MySQL will refuse to run the UPDATE or DELETE query if executed without the WHERE clause or LIMIT clause. MySQL will also refuse the query which have WHERE clause but there is no condition with the KEY column(本身翻譯吧)。可是仍是不知道這個update safe model是幹嗎用的,只能簡單猜想:爲了數據的安全。sql
SQL_SAFE_UPDATES有兩個取值:0和1。SQL_SAFE_UPDATES = 1時,不帶where和limit條件的update和delete操做語句是沒法執行的,即便是有where和limit條件但不帶key column的update和delete也不能執行。SQL_SAFE_UPDATES = 0時,update和delete操做將會順利執行。那麼很顯然,此變量的默認值是1。如圖改完後update操做順利完成: 數據庫