答案 0 :(得分:1)
您可以在查询时轻松重新编号:
select t.*, row_number() over (order by col3)
from table t;
如果您想更新数字,可以执行以下操作:
with toupdate as (
select t.*, row_number() over (order by col3) as newcol3
from table t
)
update toupdate
set col3 = newcol3;
但是,如果列是表的id,则不要更改该值。不连续的ID很好,没有理由改变这些值。并且,如果值用于外键引用,则更改值可能会破坏数据库或花费很长时间。