在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

oracle和mysql关于关联更新的差别有哪些

115次阅读
没有评论

共计 2977 个字符,预计需要花费 8 分钟才能阅读完成。

这期内容当中丸趣 TV 小编将会给大家带来有关 oracle 和 mysql 关于关联更新的差别有哪些,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

mysql 报错 ERROR 1093 (HY000): You can t specify target table a for update in FROM clause

今天网站有些数据出现异常,需要把出现异常的数据更正,具体操作是把一个表中的 publish_date 字段关联更新成同一个表中的 up_date 字段, 我们的数据是先存到 oracle,然后通过到 mysql 中的,所有异常数据存在于 oracle 和 mysql。

首先在 oracle 中更正:

SQL update  infoservice.t_publish_zbxx a set a.publish_date=(select b.up_date  from infoservice.t_publish_zbxx b where a.record_id=b.record_id) where a.publish_date to_date(2017-10-15 , yyyy-mm-dd);

然后对应着改写成 mysql 相应表和相应 sql, 居然报错。。。。

mysql update v_publish_info  a set a.publish_date=(select b.up_date  from v_publish_info b where a.id=b.id)  where a.publish_date 2017-07-15

ERROR 1093 (HY000): You can t specify target table a for update in FROM clause

解决办法:

mysql update v_publish_info  a,v_publish_info  b set a.publish_date=b.up_date  where a.id=b.id  and a.publish_date 2017-07-15

或者

1,把要更新的几列数据查询出来做为一个第三方表,然后筛选更新。

2,新建一个临时表保存查询出的数据,然后筛选更新。最后删除临时表。

具体如下:

create table liuwenhe.publish_date_temp as select id ,publish_date,up_date  from  info.v_publish_info   where publish_date 2017-07-15

update info.v_publish_info  a set  a.publish_date=(select b.up_date  from liuwenhe.publish_date_temp b where a.id=b.id)  where a.publish_date 2017-07-15

为了防止匹配不上,更新为空的问题,可以加上 exists 条件;

update info.v_publish_info  a set  a.publish_date=(select b.up_date  from liuwenhe.publish_date_temp b where a.id=b.id)  where a.publish_date 2017-07-15 and exists (select b.up_date  from liuwenhe.publish_date_temp b where a.id=b.id);

如下是关于关联更新的一些实验:

mysql:

1. 成功

mysql update  liuwenhe.publish_date_20170715  a set a.publish_date=(select b.up_date  from info.v_publish_info b where a.id=b.id)  where a.publish_date 2017-07-15  and  exists (select b.up_date  from info.v_publish_info b where a.id=b.id);

Query OK, 0 rows affected (0.00 sec)

Rows matched: 0  Changed: 0  Warnings: 0

2. 失败

mysql update  liuwenhe.publish_date_20170715  a set a.publish_date=(select b.up_date  from liuwenhe.publish_date_20170715 b where a.id=b.id)  where a.publish_date 2017-07-15

ERROR 1093 (HY000): You can t specify target table a for update in FROM clause

3. 成功

mysql update  liuwenhe.publish_date_20170715 a,liuwenhe.publish_date_20170715 b set a.publish_date=b.in_date  where  a.id=b.id and  a.publish_date 2017-07-15

Query OK, 0 rows affected (0.01 sec)

Rows matched: 0  Changed: 0  Warnings: 0

oracle:

4. 失败

SQL  update liuwenhe.top_80 a,infoservice.t_member_info b set a.login_id=b.login_id  where a.member_id=b.record_id;

update liuwenhe.top_80 a,infoservice.t_member_info b set a.login_id=b.login_id  where a.member_id=b.record_id

ERROR at line 1:

ORA-00971: missing SET keyword

5. 失败:

SQL  update liuwenhe.top_80 a,liuwenhe.top_80 b set a.login_id=b.login_id  where a.member_id=b.member_id;

update liuwenhe.top_80 a,liuwenhe.top_80 b set a.login_id=b.login_id  where a.member_id=b.member_id

ERROR at line 1:

ORA-00971: missing SET keyword

6. 成功

SQL update liuwenhe.top_80 a set a.login_id=(select b.login_id from  infoservice.t_member_info  b where a.member_id=b.record_id);

通过实验 1 和 2 比较可以知道,mysql 中是不能关联更新同一个表的,但是 oracle 中可以;实验 4 和 5 可以知道 oracle 中不能使用 update a,b set a.=b. 之类的语句;实验 3 可以知道,mysql 可以使用 update a,b set a.=b. 之类的语句来关联更新表;

上述就是丸趣 TV 小编为大家分享的 oracle 和 mysql 关于关联更新的差别有哪些了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注丸趣 TV 行业资讯频道。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-19发表,共计2977字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 久久久久久亚洲av无码精品专口 | 国产精品久久久久久久毛片 | 欧洲女人与公拘交酡视频 | 韩国一级毛片视频免费观看 | 91香蕉视频成人 | 中文人妻av久久人妻18 | 久久久久无码精品国产app | 亚洲欧美精品综合中文字幕 | 亚洲国产成人av网站 | 丰满白嫩大屁股ass 丰满爆乳无码一区二区三区 | 自偷自拍亚洲综合精品 | va视频在线 | 伊人狠狠色j香婷婷综合 | 中文字幕精品在线 | 久久精品午夜视频 | 男人天堂avav | 亚洲丁香婷婷久久一区二区 | 亚洲香蕉网久久综合影院3p | 国产三级精品三级国产 | 久久久天堂国产精品女人 | 国产热re99久久6国产精品 | 一级欧美毛片成人免费视频 | 久久综合给合久久国产免费 | 色综合99久久久无码国产精品 | 一级特级aa欧美毛片 | 女人被黑人狂躁c到高潮小说 | 日韩亚洲 | 亚洲av无码1区2区久久 | 色偷偷综合| 中国极品少妇xxxxx | 大香伊蕉在人线国产最新75 | 野花香社区在线观看 | 国产成人亚洲毛片 | 国产精品久久久久久久久久久搜索 | 国产欧美va天堂在线观看视频 | 热久久伊人 | 久久久婷婷成人综合激情 | 国产在线步兵一区二区三区 | 国产成人精品免费视频大全麻豆 | 色综合伊人色综合网站 | 在线观看丝袜 |