我有一个要在oracle中更新的表。可以假设rownum是从1到7的连续顺序
Table Have
1
2
3
4
4
4
4
Table Want
1
2
3
4
5
6
7
答案 0 :(得分:0)
如果我说对了,您需要通过添加(rownum -1)来获取UPDATE
之类的所有重复行(在您的情况下,值为4)。
请参见下面的示例。
create table have as
select case when rownum <= 4 then rownum else 4 end col1 from dual connect by level <= 7;
select col1 from have order by col1;
COL1
----------
1
2
3
4
4
4
4
update have
set col1 = col1 + rownum -1 where col1 = 4;
select col1 from have order by col1;
COL1
----------
1
2
3
4
5
6
7
答案 1 :(得分:0)
似乎您希望在该列中具有唯一的序号。
如果您不太关心条件,甚至可以
update have set col1 = rownum;