这个update语句怎么写?

tvhtb 2005-07-15 11:45:11
表A(字段有:area_code,serv_id,owner_id,user_id),area_code,serv_id联合主键
表B(字段有:serv_id,cust_id,use_cust_id)(主键为serv_id,这张用用dblink才能访问到,dblink名字为xm_db)

当A.area_code='592'并且A.serv_id=B.serv_id时,将B.cust_id赋值给A.owner_id,B.use_cust_id赋值给A.user_id。
数据量大概有1千万条,怎么写这个update语句?
...全文
312 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tvhtb 2005-07-15
  • 打赏
  • 举报
回复
b表是要dblink才能访问的,这样好像也不行的。
update A set (A.owner_id,A.user_id)=(select x.cust_id,x.user_id from B@xm_db x where A.serv_id=x.serv_id) where A.area_id='592';
这样可以么?
huangyan168168 2005-07-15
  • 打赏
  • 举报
回复
支持 zwj0712(阿张)
zjw7789 2005-07-15
  • 打赏
  • 举报
回复
应该采用zwj0712(阿张)的语句,更新A表必须带上A表的过滤条件
tvhtb 2005-07-15
  • 打赏
  • 举报
回复
多谢2位
zwj0712 2005-07-15
  • 打赏
  • 举报
回复
update A set (A.owner_id,A.user_id)=(select B.cust_id,B.user_id from B where A.serv_id=B.serv_id) where A.area_id='592'
liting78hello 2005-07-15
  • 打赏
  • 举报
回复
update a set (a.owner_id,a.user_id)=(select b.cust_id,b.use_cust_id from b where a.area_code='592' and a.serv_id=b.serv_id);

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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