- 不过滤重复的记录。
teledb=# create table teledb_pg1(id int, nickname varchar); CREATE TABLE teledb=# insert into teledb_pg1 values(3, 'pg'),(5,'test'); COPY 2 teledb=# select * from teledb_pg union all select * from teledb_pg1; id | nickname ----+------------ 1 | teledb 1 | hello,pgxc 2 | TELEDB 3 | pg 4 | 5 | test 3 | pg (7 rows)
- 过滤重复的记录。
teledb=# select * from teledb_pg union select * from teledb_pg1; id | nickname ----+------------ 1 | teledb 1 | hello,pgxc 4 | 5 | test 2 | TELEDB 3 | pg (6 rows)
- 每个子查询分布在合并结果中的使用。
teledb=# select * from (select * from teledb_pg limit 2) as t union all select * from (select * from teledb_pg1 limit 2) teledb-# ; id | nickname ----+------------ 1 | teledb 1 | hello,pgxc 5 | test 3 | pg (4 rows)