数据库版本:oracle 11gr2,我的表是这样的:
create table t_test(t_id number,t_value number)
insert into t_test (t_id) values (1);
insert into t_test (t_id) values (2);
insert into t_test (t_id) values (6);
insert into t_test (t_id) values (10);
insert into t_test (t_id) values (3);
t_id t_value
1 null
2 null
6 null
10 null
3 null
我期待的更新是这样的:
select t.t_id,row_number() over (order by t.t_id)
from t_test t
t_id row_number() over (order by t.t_id)
1 1
2 2
6 4
10 5
3 3
但是更新视图中不允许使用分析功能:
update
(select t.value,row_number() over (order by t.t_id) rn
from t_test t)
set value=rn
毫无疑问,它会导致 ORA-01732。如何放置更新查询?