PostgreSQL - Create view with autoincremental column
You can use row_number, and the easiest way is to just add a
row_number() OVER (PARTITION BY true)
field into the view. You need the PARTITION BY and using the "true" expression is the most performant way (no need for sorting like in Fabrizio Mazzoni's answer).
As @deszo said user OVER()
create view foo as (
select row_number() over (order by field), field, field2, field3 from bar
)