"Claudio Lapidus" <clapidus(at)hotmail(dot)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