update多列的幾種選擇

2021-08-30 23:32:18 字數 804 閱讀 4375

update

多列

時有如下幾種選擇

1.)教科書式寫法

update t_table a

set f1=(select f1 from testz b where a.id=b.id),

f2=(select f2 from testz b where a.id=b.id),

f3=(select f3 from testz b where a.id=b.id)

where id=2;itpub個人空間0n2q;m4h-d u+p�?ox'n

2.)教科書變種

update t_table a

set (f1,f2,f3)=(select f1,f2,f3 from testz b where a.id=b.id)

where id=2;

雖然道理和方法1一樣,卻省了不少事

3.)另類nest table寫法

update (select f1,f2,f3 from t_table where id=2)

set (f1,f2,f3)=(select f1,f2,f3 from testz b where id=2);

此方法雖然比2的

**

量要多一些,但是沒有表連線,如果兩個表都在id列有主鍵,速度應該較方法1和方法2快一些.

說明:update是乙個耗回滾段,耗重做日誌,耗時間,耗成本的操作,尤其是大表的多列update,如有必要應比較其與重新建表的效率.

update多列更新

再etl的時候,經常會遇到列轉換的問題,再對照轉換中出現多列更新的時候,一下是我總結的一些 當update多列時有如下幾種選擇 1.教科書式寫法 update t table a set f1 select f1 from testz b where a.id b.id f2 select f2 f...

多列選擇框控制項checkedListBox演示程式

清理所有正在使用的資源。protected override void dispose bool disposing base.dispose disposing region windows 窗體設計器生成的 設計器支援所需的方法 不要使用 編輯器修改 此方法的內容。p rivate void i...

選擇的UPDATE 主鍵互換

資料庫 twt001 資料表 aupkey 參考文章 sql中的case when用法 例,有如下更新條件 工資以上的職員,工資減少 工資在到之間的職員,工資增加 很容易考慮的是選擇執行兩次update語句,如下所示 條件 update personnel set salary salary 0.9...