MySQL、You are using safe update mode
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的更多相关文章
- 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 ...
- 【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 ...
- 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 ...
- 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 ...
- mysql update时报错You are using safe update mode
在使用mysql执行update的时候,如果不是用主键当where语句,会报如下错误,使用主键用于where语句中正常. ) Error Code: . You are using safe upda ...
- 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 ...
- 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 ...
- MySQL 误删数据、误更新数据(update,delete忘加where条件)
MySQL 误操作后数据恢复(update,delete忘加where条件) 关键词:mysql误删数据,mysql误更新数据 转自:https://www.cnblogs.com/gomysql/p ...
- 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 ...
随机推荐
- 为什么用户主目录下.bash_profile没有自动执行
请注意 一般登录当前用户后 .bash_profile会自动运行 如果不自动运行请查看是不是切换用户的时候使用的su 用户名而不是su - 用户名 添加中间这个 - 后 会除了切换用户外还会加载该用户 ...
- HttpServletRequest 各种方法总结(转自百度经验)
HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中,开发人员通过这个对象的方法,可以获得客户这些信息. req ...
- css background-position (图片裁取)
语法:background-position : length || length background-position : position || position 取值:length : 百分 ...
- Hive进阶(上)
Hive进阶(上) Hive进阶(上) 执行数据导入 使用Load语句 语法: 1.LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE ...
- 关于AJAX+HTML5+ASHX进行全静态页面的数据交互
及时总结项目中使用到的知识,知识在于积累. 1.HTML代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN ...
- 用Servlet实现聊天室设计
实验一 Servlet编程 一.实验目的 1.熟悉Java EE编程环境JDK和NetBeans的安装,配置和使用: 2.掌握Servlet的编写及部署: 3.掌握Servlet的工作原理和编程接 ...
- MYSQL中的普通索引,主健,唯一,全文索引区别
MYSQL索引用来快速地寻找那些具有特定值的记录,所有MySQL索引都以B-树的形式保存.如果没有索引,执行查询时MySQL必须从第一个记录开始扫描整个表的所有记录,直至找到符合要求的记录.表里面的记 ...
- hdu 4059 The Boss on Mars 容斥
题目链接 求出ai^4+a2^4+......an^4的值, ai为小于n并与n互质的数. 用容斥做, 先求出1^4+2^4+n^4的和的通项公式, 显然是一个5次方程, 然后6个方程6个未知数, 我 ...
- 自定义构造、description方法、SEL
[Objective-C]07-自定义构造方法和description方法 // 构造方法:用来初始化对象的方法,是个对象方法,”-"开头// 重写构造方法的目的:为了让对象创建出来,成 ...
- 2014年辛星解读Javascript之DOM之冒泡和捕获
上篇博客提到了Javascript事件绑定函数的三个參数.第一个是一个event.第二个是一个function.第三个是一个布尔变量.它用于指定事件传递的顺序,分为冒泡和捕获两种方式,接下来我们将揭开 ...