Oracle之with as和update用法

许久不用,又忘了,做个记录

update test b set b.code=(
with t as
(select t.id,code||'_'||row_number() over(partition by code order by id) code
from test t)
select a.code from t a where a.ID=b.ID
);

很多金融统计中,语句相当复杂。有可能会update的时候索引使用不上,看执行计划走不了hash join,数据量大的时候,适合于创建临时表。

猜你喜欢

转载自www.cnblogs.com/zhjh256/p/10037488.html