MySQL默认模式是sql_safe_updates=1的。在这个模式下不管你是update还是delete一行where 条件都要指定主键。如果where条件只出现的不是主键就会出错。

例子:

  set sql_safe_updates =1;--开始安全更新、这个是我这个例子的前提。

  --第一步:建立两个表

  create table t(x int,y int);

  create table t2(x int primary key,y int);

  --第二步:向表中插入数据

  insert into t(x,y) values(1,1),(2,2),(3,3);

  insert into t2(x,y) values(1,1),(2,2),(3,3);

  --第三步:测试安全更新模式对update delete 的影响。

  update t set y =100 where x=1;--这个会出报错、You are using safe update mode......

  update t2 set y=100 where x=1;--这个就没有事。因为x这表t2中是主键、而在表t中不是。

  --解决方案:

  为了对t表的更新也可以完成、我们就要在update 语句前加上一句。

  set sql_safe_updates =0;--禁用这个模式就可以了。

MySQL、You are using safe update mode的更多相关文章

  1. MySQL错误:You are using safe update mode and you tried to update a table without a WHERE that uses a K

    转载自:http://blog.csdn.net/dragonpeng2008/article/details/7279590 Error: 1175 SQLSTATE: HY000 (ER_UPDA ...

  2. 【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 mode, toggle the option in Preferences -> SQL Queries and reconnect.

    Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE tha ...

  3. 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 mode, toggle the option in Preferences -> SQL easonjim

    错误: Error Code: . You are using safe update mode and you tried to update a table without a WHERE tha ...

  4. Mysql报错Error Code: 1175. You are using safe update

    使用MySQL执行update的时候报错:Error Code: 1175. You are using safe update mode and you tried to update a tabl ...

  5. mysql update时报错You are using safe update mode

    在使用mysql执行update的时候,如果不是用主键当where语句,会报如下错误,使用主键用于where语句中正常. ) Error Code: . You are using safe upda ...

  6. Mysql update error: Error Code: 1175. You are using safe update mode and you tried to update a table

    Mysql update error: Error Code: 1175. You are using safe update mode and you tried to update a table ...

  7. mysql错误:Error Code: 1175. You are using safe update mode and you tried to update a table……

    今天遇到一个mysql错误:   Error Code: . You are using safe update mode and you tried to update a table withou ...

  8. MySQL 误删数据、误更新数据(update,delete忘加where条件)

    MySQL 误操作后数据恢复(update,delete忘加where条件) 关键词:mysql误删数据,mysql误更新数据 转自:https://www.cnblogs.com/gomysql/p ...

  9. mysql更新字段值提示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

    1 引言 当更新字段缺少where语句时,mysql会提示一下错误代码: Error Code: 1175. You are using safe update mode and you tried ...

随机推荐

  1. Struts 2.x 与Spring4.x整合出现:No mapping found for dependency [type=java.lang.String, name='actionPackages...

    Struts2.16与Spring4.x整合出错: Caused by: java.lang.RuntimeException: com.opensymphony.xwork2.inject.Depe ...

  2. 一个证书多次使用-导出p12文件

    在苹果开发者网站申请的证书,是授权mac设备的开发或者发布的证书,这意味着一个设备对应一个证书,但是99美元账号只允许生成3个发布证书,两个开发证书,这满足不了多mac设备的使用,使用p12文件可以解 ...

  3. Android 数据适配器

    把复杂的数据(数组.链表.数据库.集合等)填充到指定的视图界面上.   arrayAdapter(数组适配器):      用于绑定一些格式单一的数据,数据源:数据或者集合.   private Li ...

  4. HTML前端技术(JS的使用,包括数组和字符串)

    <script type="text/javascript"> /* JS 数组的操作 //concat 连接两个或更多的数组,并返回结果. var arr1 = ne ...

  5. 你的阅读造就了你 You are what you read

    在豆瓣上看到的一篇很有思想和正能量的文章,在这里请允许我用原创的方式来呈现给大家.如果你是在校的大学生或者研究生博士生,这篇文章会让你有很多的共鸣.如果你已真正的踏入这个社会,也将受益匪浅.   电脑 ...

  6. codeforces 659C . Tanya and Toys 二分

    题目链接 将给出的已经有了的排序, 在前面加上0, 后面加上1e9+1. 然后对相邻的两项判断. 如果相邻两项之间的数的和小于m, 那么全都选上, m减去相应的值. 如果大于m, 那么二分判断最多能选 ...

  7. select,poll,epoll之api笔记

    参考:http://www.cnblogs.com/Anker/p/3265058.html select /* According to POSIX.1-2001 */ #include <s ...

  8. Ajax与C#应用详细实例

    实现刷新的方法主要是Ajax,本文档实现Ajax有两个方法(Jquery 和 W3C的JS方法):其次,使用JS也可以实现刷新数据不刷新页面(详见其他刷新页面方法JS实现):对于CallbackRef ...

  9. Cloning Java objects using serialization

    Sometimes you need to clone objects, and sometimes you can't use their clone method, and sometimes s ...

  10. 获取EIP(汇编语言直接给Delphi变量赋值)

    var EIP: Cardinal; procedure GetEIP(); stdcall; asm pop eax; mov EIP,eax; push eax; end; procedure T ...