多表更新问题

sharpfire 2010-06-02 01:52:27
我有多张表,现在要用一个update语句来更新这些表里的同样一个字段,比如说createUser
这些表之间没有关联
请问这个sql怎么写
...全文
86 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
碧水幽幽泉 2010-06-04
  • 打赏
  • 举报
回复
要用一个update语句来更新这些表里的同样一个字段
用触发器或存储过程!
但是触发器在效率和性能比不上存储过程!
zzbinfo 2010-06-04
  • 打赏
  • 举报
回复
呵呵,用触发器好点吧,其他的估计没有办法
kingkingzhu 2010-06-02
  • 打赏
  • 举报
回复
这个想法没前途 多写几句sql吧
半世码农 2010-06-02
  • 打赏
  • 举报
回复
用存储过程或触发器吧,表没关联,一个sql肯定实现不了
ojuju10 2010-06-02
  • 打赏
  • 举报
回复


用merge,例子:

merge into lzyrealamount_gsm_0912 a
using (select svcnum, sum(chrgamount) as chrgamount
from lzysvcnum_acctinsht
group by svcnum ) b
on(a.msisdn=b.svcnum )
when matched then update set (a.chargefee=b.chrgamount)
ngx20080110 2010-06-02
  • 打赏
  • 举报
回复
用觸發器吧。
create or replace trigger tri_update
after update of createUser on table1
begin
update table2 set createUser = :new.createUser where userId = :old.userId;
update table3 set createUser = :new.createUser where userId = :old.userId; update table4 set createUser = :new.createUser where userId = :old.userId;

end;

17,086

社区成员

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

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