执行插入操作时报错:safe update mode(调用了触发器)
来源:互联网 发布:安卓网络测试软件 编辑:程序博客网 时间:2024/05/22 00:14
今天在测试触发器时,触发器如下:
DELIMITER $$
create trigger addCount after insert on test.student
for each row
begin
update test.student_count set count = (select count(*) from test.student);
end$$
创建好了触发器,但是在执行插入操作时报错,查了一下,结果如下:
在mysql5中,可以设置safe mode,比如在一个更新语句中
UPDATE table_name SET bDeleted=0;执行时会错误,报:
You are using safe update mode and you tried to update a table without a WHERE clause that uses a KEY column.”
原因是在safe mode下,要强制安全点,update只能跟where了,
要取消这个限制,可以:
SET SQL_SAFE_UPDATES=0;
即可
--------------------------------------------------------------------------------------------------------------
今天删除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 Editor -> Query Editor and reconnect.
后来通过搜索资料,发现mysql有个叫SQL_SAFE_UPDATES的变量,为了数据库更新操作的安全性,此值默认为1,所以才会出现更新失败的情况。
下面是SQL_SAFE_UPDATES变量为0和1时的取值说明:
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。
所以,出现1175错误的时候,可以先设置SQL_SAFE_UPDATES的值为0,然后再执行更新,例如:
SQL_SAFE_UPDATES = 0;
delete from testTable where name='张三';
- 执行插入操作时报错:safe update mode(调用了触发器)
- MYSQL SAFE UPDATE MODE
- 关于MySQL执行更新操作时的 You are using safe update mode and you tried to update a table without
- MySQL执行插入操作时报错1366 - Incorrect string value
- MySql 删除、更改操作报错You are using safe update mode and you tried to update a table without a WHERE that u
- 1175. You are using safe update mode
- mysql读书笔记---mysql safe update mode
- mysql You are using safe update mode
- mybatis执行update批量更新时报错
- 在数据库中执行删除delete语句时出现:You are using safe update mode and you tried to update a table without a WHERE
- Error Code: 1175. You are using safe update mode
- Error Code: 1175. You are using safe update mode
- MySQL Error:You are using safe update mode and.....
- 【java项目实践】mybatis执行update批量更新时报错
- Ubuntu 16.04 执行 apt update 更新时报错的解决办法
- 无意之中 实现了个两表互相调用插入触发器的代码
- safe update
- 数据库 safe You are using safe update mode and you tried to update a table without a WHERE
- django中使用静态文件
- SQL 取分组后前三条数据
- Java日期格式化
- WinForm程序无Framwork运行
- 三层与MVC
- 执行插入操作时报错:safe update mode(调用了触发器)
- Linux显示中文—韩文—日文-Zhcon使用方法
- 顺序表基本操作(插入、删除)
- windows下tomcat服务器部署web程序
- jquery ajax跨域请求获取返回值(jsonp格式)
- FLEX AIR桌面应用——ChildPro
- 代理服务器的工作原理
- C/C++编译的程序占用的内存情况详细解析
- BNUOJ 4156 Chocolate Buying