Re: marking record origin in views

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: marking record origin in views
Дата
Msg-id 15132.1069861677@sss.pgh.pa.us
обсуждение исходный текст
Ответ на marking record origin in views  ("Claudio Lapidus" <clapidus@hotmail.com>)
Список pgsql-general
"Claudio Lapidus" <clapidus@hotmail.com> writes:
> create view v1 as select * from t1 union select * from t2;
> But I would like to have an extra field (in the view) with the table name of
> the particular record source. How can this be done?

What's wrong with

create view v1 as
  select *,'t1'::text as label from t1
 union
  select *,'t2'::text from t2;

Obviously, you can pick any field values and datatype you want.

Hint: use UNION ALL, not UNION.

            regards, tom lane

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

Предыдущее
От: "Jason Tesser"
Дата:
Сообщение: Re: pam authentication for postgres
Следующее
От: Greg Stark
Дата:
Сообщение: Re: marking record origin in views