Re: Automatic row numbering / sequence in view ?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Automatic row numbering / sequence in view ?
Дата
Msg-id b42b73150610100749j366f34aeje4c24381e08d1fb1@mail.gmail.com
обсуждение исходный текст
Ответ на Automatic row numbering / sequence in view ?  (Arnaud Lesauvage <thewild@freesurf.fr>)
Ответы Re: Automatic row numbering / sequence in view ?  (Arnaud Lesauvage <thewild@freesurf.fr>)
Список pgsql-general
On 10/10/06, Arnaud Lesauvage <thewild@freesurf.fr> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Arnaud Lesauvage
Дата:
Сообщение: Automatic row numbering / sequence in view ?
Следующее
От: Arnaud Lesauvage
Дата:
Сообщение: Re: Automatic row numbering / sequence in view ?