oracle批量更新操作

2021-07-09 01:29:53 字數 637 閱讀 2056

專案問題是這樣的,有一張表tb_user_market使用者記錄繫結使用者,一開始沒有欄位system_date,後來新加的,該欄位使用者記錄使用者繫結的時間;還有一張表tb_log_user_market

裡面記錄的是使用者的繫結歷史資訊,可能有重複的使用者記錄,即使用者先繫結後解綁又繫結的情況,該錶有個字段bind_date用於記錄繫結時間,現在需要將bind_date欄位的時間同步到tb_user_market表的system_date 的相應使用者。sql語句如下:

update tb_user_market t5

set t5.system_date = (select min(t.bind_dat)

from tb_log_user_market t

where t.user_market_no = t5.user_market_no)

where t5.system_date is null

1.批量刪除:

刪除第10條以後的資料:

delete from tb_user_market where rowid not in (select rowid from tb_user_market where rownum<=10)

Oracle批量更新

需求 將t2 t statbuf 表中id和t1 t mt 表相同的記錄更新進t1表。1.錯誤的寫法 1update table name t1 set a,b,c select a,b,c from table name 2 t2 where t1.a t2.a 這種寫法,會更新t1表中的所有行 ...

oracle批量更新資料

目的 兩個表t1,t2,t1裡面的字段,id,name,t2也是,將t2表和t1表裡面相等的id的記錄的name欄位更新到t1表裡面 1 update t1 set name select t2.name from t2 where t2.id t1.id where exits select 1 ...

oracle批量操作

批量新增 declare cursor cur is select a.xh,a.zyh,a.bjh,a.xm,a.xbm,a.sfzjh,a.csrq from xsxxgl xsjbxx a where not exists select 1 from zs xsxx2 b where a.xh...