QUERY: create table v1 (x int4, y int4, z int4);
QUERY: insert into v1 values (1, 2, 3);
QUERY: insert into v1 values (1, 3, 4);
QUERY: insert into v1 values (1, 4, 5);
QUERY: insert into v1 values (1, 2, 6);
QUERY: create view vv1 as select x from v1;
QUERY: create view vv2 as select y from v1;
QUERY: create view vv3 as select z from v1;
QUERY: select * from vv1;
x  
-- 
1  
1  
1  
1  
QUERY: select * from vv2;
y  
-- 
2  
3  
4  
2  
QUERY: select * from vv3;
z  
-- 
3  
4  
5  
6  
QUERY: drop view vv2;
QUERY: drop view vv3;
QUERY: create view vv as select * from vv1;
QUERY: select * from vv;
x  
-- 
1  
1  
1  
1  
QUERY: create view vv2 as select x from vv;
QUERY: select * from vv2;
x  
-- 
1  
1  
1  
1  
QUERY: drop view vv;
QUERY: drop view vv1;
QUERY: drop view vv2;
QUERY: create view vv1 as select x, z from v1;
QUERY: create view vv2 as select y, z from v1;
QUERY: create view vv3 as select y, z, x from v1;
QUERY: select * from vv1;
x  z  
-- -- 
1  3  
1  4  
1  5  
1  6  
QUERY: select * from vv2;
y  z  
-- -- 
2  3  
3  4  
4  5  
2  6  
QUERY: select * from vv3;
y  z  x  
-- -- -- 
2  3  1  
3  4  1  
4  5  1  
2  6  1  
QUERY: drop view vv1;
QUERY: drop view vv2;
QUERY: drop view vv3;
QUERY: create view vv1 as select x as a, z as b, y as c from v1;
QUERY: select * from vv1;
a  b  c  
-- -- -- 
1  3  2  
1  4  3  
1  5  4  
1  6  2  
QUERY: drop view vv1;
QUERY: create view vv1 as select z, 100 as p, x as q from v1;
QUERY: select * from vv1;
z  p    q  
-- ---- -- 
3  100  1  
4  100  1  
5  100  1  
6  100  1  
QUERY: drop view vv1;
QUERY: create view vv1 as select x + y as xy, z from v1;
QUERY: select * from vv1;
xy  z  
--- -- 
3   3  
4   4  
5   5  
3   6  
QUERY: drop view vv1;
QUERY: create table v2 (a int4);
QUERY: insert into v2 values (2);
QUERY: insert into v2 values (3);
QUERY: create view vv1 as select y, z from v1, v2 where y = a;
QUERY: select * from vv1;
y  z  
-- -- 
2  6  
2  3  
3  4  
QUERY: drop view vv1;
QUERY: create view vv1 as select y - x as yx, z, a from v1, v2 where (x + y) > 3;
QUERY: select * from vv1;
yx  z  a  
--- -- -- 
2   4  2  
3   5  2  
2   4  3  
3   5  3  
QUERY: drop view vv1;
QUERY: drop table v1, v2;
