1、根据条件更新表里的某个字段值,如下:update test t set t.b_salary =case when t.b_id = 5 then 5000 when t.b_id = 6 the
1、根据条件更新表里的某个字段值,如下:
update test t set t.b_salary =
case when t.b_id = 5 then 5000
when t.b_id = 6 then 6000
when t.b_id = 7 then 7000
end
where t.b_id in (5,6,7)
说明: where条件部分一定要把记录限制为只需要更新的部分,否则其他部分会被更新为空。
2、2表关联update某个字段的
a)、一对一关联
update test1 t set t.a_salary =
( select a.b_salary from test a where a.b_id = t.a_id
)
where exists (select 1 from test a where a.b_id = t.a_id )
;
commit;
b)、一对多关联
(1)、目标表一个ID存在多条记录,源头是一个ID存一条记录,此种场景和一对一没有区别
update test1 t set t.a_salary =
( select a.b_salary from test a where a.b_id = t.a_id
)
where exists (select 1 from test a where a.b_id = t.a_id )
;
commit;
(2)、目标表一个ID一条记录,源头是一个ID存在多条记录
报错ora-01427 :单行子查询返回多条记录
本质上是目标表在源表根据关联ID去找的时候,一个ID找到了多条记录,返回给目标表的一条记录里目标值为多个。
若返回多个记录值都是一样的,返回任意一条都可以,则此时对返回值加上max,写法如下:
update test1 t set t.a_salary =
( select max(a.b_salary) from test a where a.b_id = t.a_id
)
where exists (select 1 from test a where a.b_id = t.a_id )
c)、多对多关联
报错ora-01427 :单行子查询返回多条记录
本质上是目标表在源表根据关联ID去找的时候,一个ID找到了多条记录,返回给目标表的一条记录里目标值为多个。
若返回多个记录值都是一样的,返回任意一条都可以,则此时对返回值加上max,写法如下:
update test1 t set t.a_salary =
( select max(a.b_salary) from test a where a.b_id = t.a_id
)
where exists (select 1 from test a where a.b_id = t.a_id )
;
commit;
说明: exists的作用,防止更新没有关联上的记录。若不加exists ,则目标表中无关记录会被置空。故这个exists一定要加上。
总结:
1、对于更新表内容,一定要把更新内容限制在只要更新的部分,where部分一定要有。
2、2表关联update的时候,目标表根据关联ID从源表去找记录的时候,,存在ID重复的记录和目标表没有关系,要注意源表存在ID重复的记录。
对于大表关联update,普通的写法,根本跑不动,百度了一下,根据rowid来更新,果然可以跑动。方法如下:
--t1 为源表
--t2 为要更新的目标表
declare
cursor cur is
select
a.t1_name, b.rowid row_id
from t1 a, t2 b
where a.t1_id = b.t2_id
order by b.rowid;
v_counter number;
begin
v_counter := 0;
for row in cur loop
update t2 t
set t.t2_name = row.t1_name
where rowid = row.row_id;
v_counter := v_counter + 1;
if (v_counter >= 1000) then
commit;
v_counter := 0;
end if;
end loop;
commit;
end;
相关阅读:
Oracle update执行计划原理解析与优化
Oracle 中 update nowait 的使用方法
Oracle存储过程使用实例之update的使用
Oracle update关联表的思路总结
Oracle for update of 和 for update区别

PrimeFactor−Innumbertheory,theprimefactorsofapositiveintegeraretheprimenumbersthatdividethatintegerexactly.Theprocessoffindingthesenumbersiscalledintegerfactorization,orprimefactorization.Example−Primefactorsof288are:288=2x2x2x2x2

2025年全球数字虚拟币交易平台竞争激烈,本文根据交易量、安全性、用户体验等指标,权威发布2025年全球十大数字虚拟币交易平台排行榜。OKX凭借强大的技术实力和全球化运营策略居首,Binance以高流动性和低费用紧随其后。Gate.io、Coinbase、Kraken等平台凭借各自优势稳居前列。榜单涵盖Huobi、KuCoin、Bitfinex、Crypto.com和Gemini等交易平台,各有特色,但投资需谨慎。选择平台需考虑安全性、流动性、费用、用户体验、币种选择及监管合规性等因素,理性投资

虚拟货币十大交易平台排行榜(2025年最新): 币安:全球龙头,高流动性,监管受关注。 OKX:庞大用户基数,支持多种币种,提供杠杆交易。 Gate.io:资深交易所,多种法币支付方式,提供多种交易对和投资产品。 Bitget:衍生品交易所,高流动性,低费用。 火币:老牌交易所,支持多种币种和交易对。 Coinbase:美国知名交易所,受监管严格。 Phemex等等。

十大数字货币交易平台:1. OKX,2. Binance,3. Gate.io,4. Huobi Global,5. Kraken,6. Coinbase,7. KuCoin,8. Bitfinex,9. Crypto.com,10. Gemini,这些交易所各具特色,用户可根据安全性、费用、币种选择、用户界面和客户支持等因素选择适合自己的平台。

本文推荐十个数字货币交易App:1. OKX;2. Binance;3. Gate.io;4. Huobi Global;5. Kraken;6. Coinbase;7. KuCoin;8. Crypto.com;9. Bitfinex;10. Poloniex。选择平台需考虑安全性、流动性、交易费用、币种选择、用户界面、客服支持及法规合规性等因素,谨慎评估风险,切勿盲目跟风。

靠谱的数字货币平台包括:1. OKX,2. Binance,3. Gate.io,4. Huobi Global,5. Kraken,6. Coinbase,7. KuCoin,8. Bitfinex,9. Crypto.com,10. Gemini,这些交易所各具特色,用户可根据安全性、费用、币种选择、用户界面和客户支持等因素选择适合自己的平台。

十大虚拟币交易平台排名依次为:1. OKX;2. Binance;3. Gate.io;4. Huobi Global;5. Kraken;6. Coinbase;7. KuCoin;8. Crypto.com;9. Bitfinex;10. Gemini。 排名基于平台流动性、币种选择、安全性、用户体验、手续费及合规性等因素综合考量,但仅供参考,投资需谨慎,风险自担。

随着数字货币市场的繁荣,本文列出了十大数字货币交易 App 排行榜,以帮助投资者选择可靠且易用的平台。排行榜包括币安、Coinbase、Gemini、Kraken、FTX、Huobi、OKX、Bitfinex、Crypto.com 和 Gate.io。这些 App 提供了广泛的交易对、安全可靠的平台、低交易费用和高流动性等优势。投资者应根据安全、用户友好性、交易费用、流动性、支持的币种和客户服务等因素,选择最符合他们需求的 App。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
