第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Oracle:如何使用UPSERT(更新或插入到表中?)

Oracle:如何使用UPSERT(更新或插入到表中?)

慕田峪7331174 2019-07-02 16:02:23
Oracle:如何使用UPSERT(更新或插入到表中?)UPSERT操作更新或插入表中的一行,這取決于表是否已經(jīng)有與數(shù)據(jù)匹配的行:if table t has a row exists that has key X:     update t set mystuff... where mykey=Xelse     insert into t mystuff...由于Oracle沒有特定的UPSERT語句,那么最好的方法是什么?
查看完整描述

3 回答

?
蕪湖不蕪

TA貢獻1796條經(jīng)驗 獲得超7個贊

合并的另一種選擇(“舊式方式”):

begin
   insert into t (mykey, mystuff) 
      values ('X', 123);exception   when dup_val_on_index then
      update t 
      set    mystuff = 123 
      where  mykey = 'X';end;


查看完整回答
反對 回復(fù) 2019-07-02
?
紅糖糍粑

TA貢獻1815條經(jīng)驗 獲得超6個贊

這個合并語句將數(shù)據(jù)合并到兩個表之間。使用DUAL允許我們使用這個命令。請注意,這不受并發(fā)訪問的保護。


create or replace

procedure ups(xa number)

as

begin

    merge into mergetest m using dual on (a = xa)

         when not matched then insert (a,b) values (xa,1)

             when matched then update set b = b+1;

end ups;

/

drop table mergetest;

create table mergetest(a number, b number);

call ups(10);

call ups(10);

call ups(20);

select * from mergetest;


A                      B

---------------------- ----------------------

10                     2

20                     1


查看完整回答
反對 回復(fù) 2019-07-02
  • 3 回答
  • 0 關(guān)注
  • 4276 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號