mysql Error1093错误
发表于:2025-11-12 作者:千家信息网编辑
千家信息网最后更新 2025年11月12日,场景演示:mysql> create table test(id int,name varchar(12),primary key(id));Query OK, 0 rows affected (0.
千家信息网最后更新 2025年11月12日mysql Error1093错误
场景演示:mysql> create table test(id int,name varchar(12),primary key(id));Query OK, 0 rows affected (0.04 sec)mysql> insert into test values(1,'ttt');Query OK, 1 row affected (0.00 sec)mysql> insert into test values(2,'ttt');Query OK, 1 row affected (0.00 sec)mysql> commit;Query OK, 0 rows affected (0.00 sec)mysql> update test set name='aaaa' where id in (select id from test);ERROR 1093 (HY000): You can't specify target table 'test' for update in FROM clause
官方说明:
Error: 1093 SQLSTATE: HY000 (ER_UPDATE_TABLE_USED)
Message: You can't specify target table '%s' for update in FROM clause
This error occurs for attempts to select from and modify the same table within a single statement. If the select attempt occurs within a derived table, you can avoid this error by setting the derived_merge flag of the optimizer_switch system variable to force the subquery to be materialized into a temporary table, which effectively causes it to be a different table from the one modified. See Section 9.2.2.3, "Optimizing Derived Tables and View References".
mysql不支持,在一条语句对同一个表,先查询再更新的操作。
解决方法1:改成sql
比如:利用临时表
mysql> update test set name='aaaa' where id in (select id from (select id from test)c);Query OK, 2 rows affected (0.02 sec)Rows matched: 2 Changed: 2 Warnings: 0
解决方法2:
官方说:可以通过设置optimizer_switch的 derived_merge参数来解决。
备注:Oracle是不会这个问题的
官方
方法
参数
可以通过
场景
备注
语句
问题
支持
更新
查询
演示
错误
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
bartender数据库共享
上海迪凯标识嵌入式软件开发
计算机网络技术的工资
数据库右外连接什么意思
晟东网络技术有限公司
服务器后面有个蓝色的灯是什么
sql数据库重启
杭州移动网络安全宣传视频
天播网络机顶盒怎样连播放服务器
服务器的配置与管理技术
计算机网络技术资料文章
佳能复印机打印服务器
尔雅计算机网络技术
暗黑3最新数据库
360网络安全新模式
关于医疗软件开发的有那些名人
服务器宕机怎么处理
德州联想服务器代理怎么收费
杭州软件开发平台搭建
安卓手机显示数据库异常怎么处理
河南小管家网络技术
海南常规软件开发预算
网络安全词语大全
天龙八部服务器命名规则
数据库优化和锁超时
win服务器怎么看操作日志
cpugpu服务器功耗
网络安全工作总结机关单位
java上传图片到服务器
高中网络技术应用 说课稿