我有一张桌子,我想更新一下甲骨文。假设行号从1到7顺序排列是可以的。
Table Have
1
2
3
4
4
4
4
Table Want
1
2
3
4
5
6
7发布于 2018-07-30 20:43:44
您似乎希望在该列中有唯一的序列号。
如果你不太关心条件,你甚至可以
update have set col1 = rownum;发布于 2018-07-30 19:11:23
如果我说得对,通过添加(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
7https://stackoverflow.com/questions/51599911
复制相似问题