select row_number() over (order by <field> nulls last) as rownum, *
from foo_tbl
order by <field>
If order is not necessary, this answer may also be simplified:
select row_number() over(), * -- notice: no fields are needed
from foo_tbl
SQL Fiddle Proof of Concept
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…