使用窗口函数row_number()
select row_number() OVER (ORDER BY id) as rownum,* from score;
如果不关心排序,可以这样select row_number() over() as rownum,* from score;