MySql 修改数据出错 using safe update mode

Winter

2020-03-16

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

第1680篇《MySql 修改数据出错 using safe update mode》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

1个回答
Winter 2020.03.16

连接到数据库后,查看当前mysql的安全模式的状态

mysql> show variables like 'sql_safe_updates'; +------------------+-------+ | Variable_name    | Value | +------------------+-------+ | sql_safe_updates | ON    | +------------------+-------+ 1 row in set (0.00 sec)

上面查询命令实例表示当前mysql处于安全模式打开的状态。
set sql_safe_updates=1; //安全模式打开状态
set sql_safe_updates=0; //安全模式关闭状态

如果设置了sql_safe_updates=1,那么update语句必须满足如下条件之一才能执行成功
1)使用where子句,并且where子句中列必须为prefix索引列
2)使用limit
3)同时使用where子句和limit(此时where子句中列可以不是索引列)

delete语句必须满足如下条件之一才能执行成功
1)使用where子句,并且where子句中列必须为prefix索引列
2)同时使用where子句和limit(此时where子句中列可以不是索引列)

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android