Search Postgresql Archives

Re: Automatic row numbering / sequence in view ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/10/06, Arnaud Lesauvage <thewild@xxxxxxxxxxx> wrote:
Hi List !

I need to add a column to a view, which would contain an automatically
generated sequence.
An automatic row numbering would do the trick (I only need unique
numbers, that's all), but I don't even know how to achieve this.
Does anybody have a solution for this problem ?

sure a sequence works. try this:

create sequence foo;

create view foobar as select *, nextval('foo') from bar;

If your query is complex, i would consider it to be good style to push
the real view into a subquery, such as:

select q.*, nextval('foo') from
(
 [complex query here]
) q;

merlin


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux