John Macl
John Macl

Reputation: 331

Merge 3 tables in one table

I have 3 tables (t1, t2, t3) in postgresql. they all have same number of columns (168 cols) with same type and overall 300k rows.

How can I add all of them in one table?

Upvotes: 0

Views: 79

Answers (1)

roman
roman

Reputation: 117337

insert into t4
select * from t1
union all
select * from t2
union all
select * from t3

or, if you want to create table during select:

select * into t4 from t1
union all
select * from t2
union all
select * from t3;

SQL FIDDLE EXAMPLE

Upvotes: 2

Related Questions