作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个表,其中包含 69000 条记录
。现在,如何添加一个新列(比如索引),它应该包含 第一行的值 1,第二行的值 2 ....等等
。
我想要下面的结果
id name index
--------------------------
9796896 sandy 1
796869 raj 2
最佳答案
添加列并用类似的东西更新它:
with cte as
(
select *
, rank() over (order by id desc) as ranker
from test
)
update test
set index = ranker
from cte
where cte.id = test.id;
关于sql - 向postgresql中的列添加递增值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57819570/
我是一名优秀的程序员,十分优秀!