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. iOS程序启动原理(简单)

    1.执行main -> 执行UIApplicationMain UIApplicationMain底层实现 1.创建UIApplication对象 2.创建UIApplication代理对象 3 ...

  2. matlab差分算法

    今天实现了<一类求解方程全部根的改进差分进化算法>(by 宁桂英,周永权),虽然最后的实现结果并没有文中分析的那么好,但是本文依然是给了一个求解多项式全部实根的基本思路.思路是对的,利用了 ...

  3. C语言实现有序二叉树(1)

    在cpp中使用的C语言 头文件 /* 有序二叉树 BsTree */ #ifndef _BT_H #define _BT_H /*节点*/ typedef struct BsTreeNode { in ...

  4. leetcode Reverse Nodes in k-Group python

    # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = ...

  5. CentOS6安装Mysql5.7.10亲测

    亲测验证适用于5.7.10 1. 获得二进制文件 wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.10-linux-glibc2.5-x8 ...

  6. 001.web前端-学习了解

    学习web前端开发基础技术需要掌握:HTML.CSS.JavaScript语言.下面我们就来了解下这三门技术都是用来实现什么的: 1.html(Hypertext Markup Language)—— ...

  7. The number of positions

    Description The number of positions time limit per test: 0.5 second memory limit per test: 256 megab ...

  8. 得到IP包的数据意义(简单实现例子)

    #include <stdio.h> #include <unistd.h> #include <linux/if_ether.h> #include <li ...

  9. Deleted pointer causes undefined behaviour

    这文章是早期闲得用英文写的,删除了怪可惜的,贴出来证明自己会英文算了... Occasionally,on stackoverflow.com,I found a classic problem wh ...

  10. asp.net mvc 不找其他view模板,只找cshtml

    asp.net mvc 默认找view文件时,依次找后辍名为aspx.ascx.cshtml.vbhtml的view文件.但是项目住住用C#+Razor开发,这样找,岂不有性能损失. 添加以下代码: ...