I would like to write a view that is essentially something simple select a + b, * from table_name
and will always truly include all columns in table_name
, even when I add or remove them.
If I do the following:
create database viewtest;
\c viewtest
create table a (x text);
create view b as select * from a;
alter table a add y text;
select * from b;
x
---
(0 rows)
select * from a;
x | y
---+---
(0 rows)
\d+ b
View "public.b"
Column | Type | Modifiers | Storage | Description
--------+------+-----------+----------+-------------
x | text | | extended |
View definition:
SELECT a.x
FROM a;
I want to essentially create a view where the definition includes *
rather than an explicit list of the columns in the table when I created the view. Maybe I'm crazy, but this seems like a practical use case and I can't figure out how to do it for the life of me.