100分求解 ,在线等待

吴泉 2004-10-29 02:01:54
我们现在用的一个系统,现在需要将其中两个表的一个字段更新成为

a(ida,deviceno,...) ,b(idb,deviceno,newdeviceno)
其中b表是基础表,a表中的Deviceno数据与b表中的Deviceno关联,
现在我们要将a表中的Deviceno 更新成为符合新的规则的b.newDeviceno,
b表中有8000多条数据,a表有50多万条数据,有什么好方法能够快速更新?
...全文
99 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
biliky 2004-10-29
  • 打赏
  • 举报
回复
50小时??不至于这么慢吧?要修改的字段上建有索引吗?大数据量插入修改操作时对索引的维护也是数据库的一大工作啊。
lialin 2004-10-29
  • 打赏
  • 举报
回复
由于这个更新涉及的数据大,用的回滚段大,因此时间会变的很慢,我感觉用存储过程试一下,按一定数据量提交一次,这样或许会快一些!
zhaokeke2004 2004-10-29
  • 打赏
  • 举报
回复
update a set a.deviceno=(select b.deviceno from b where b.deviceno=a.deviceno)
吴泉 2004-10-29
  • 打赏
  • 举报
回复
我估计要>50小时才能 完成
lialin 2004-10-29
  • 打赏
  • 举报
回复
其它的方法也不是很多哦,只有楼上说的那样了!
bluelamb 2004-10-29
  • 打赏
  • 举报
回复
update a set a.deviceno=(select b.deviceno from b where b.deviceno=a.deviceno)
bzszp 2004-10-29
  • 打赏
  • 举报
回复
如果a.deviceno上面有索引,如果可以的话,先去掉,update后再创建。
liuyi8903 2004-10-29
  • 打赏
  • 举报
回复
update a set a.deviceno=(select b.deviceno from b where b.deviceno=a.deviceno)
ORARichard 2004-10-29
  • 打赏
  • 举报
回复
你有50多万条记录可能会被更新,不会很快的
ORARichard 2004-10-29
  • 打赏
  • 举报
回复
update a set deviceno=(select newdeviceno from b where a.deviceno=b.deviceno) where exists(select 1 from b where a.deviceno=b.deviceno)
吴泉 2004-10-29
  • 打赏
  • 举报
回复
有唯一性约束的。

不过 我测试过了,速度很慢
biliky 2004-10-29
  • 打赏
  • 举报
回复
不知道你的b表的deviceno是否有唯一约束,如果有,则可以
update a set deviceno=(select newdeviceno from b where b.deviceno=a.deviceno);

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧