在作数据库实验的时候对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操做顺利完成: 数据库