mysql Error1093错误
发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,场景演示:mysql> create table test(id int,name varchar(12),primary key(id));Query OK, 0 rows affected (0.
千家信息网最后更新 2026年11月03日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安全错误
数据库的锁怎样保障安全
有格互联网科技
互联网通讯科技
互联网 科技公司
互联网科技金融公司
亿账通互联网科技
新浪科技互联网
火传媒上海互联网科技
联恩商钥互联网科技有限公司
哈尔滨秒房互联网科技有限公司
互联网经济与金融科技
武汉健翔互联网络科技有限公司
江阴互联网智能科技产品进口
洛阳昕诺飞互联网科技有限公司
恒生互联网科技业指数调整周期
长沙渺峰互联网科技有限公司
银川新华互联网科技学校原画
互联网科技大会大佬
互联网领先科技成果宣传视频
科技互联网专业务虚会材料
互联网大会出现的黑科技
湖北九亚互联网络科技有限公司
深圳市人人互联网科技有限公司
科技大学互联网专业好不好
创业天下互联网科技有限公司
成都互联网科技公司100强
智腾互联网科技有限公司
高科技互联网发展前景如何
长沙互联网科技
互联网科技接地气
上海旺乐尼互联网科技有限公司