Append a list of tables to an empty table to form a whole table

From: Shaozhong SHI <shishaozhong(at)gmail(dot)com>
To: pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Append a list of tables to an empty table to form a whole table
Date: 2022-10-14 06:00:24
Message-ID: CA+i5JwaD2rz-jJdm9_SK=88z=J0SDNmij98hMZxCwLuHxbz2Mw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

How best to append a list of tables to an empty table to form a whole table?

Pseudo codes show the desirable logic.

There are a list of tables with exactly same colums
table_a
table_b
table_c

Create an empty table emp_table

Foreach a_name in ARRAY ARRAY['table_a', 'table_b', 'table_c'] loop
insert into em_table as select * from table a_name

end loop;

Can something like that be done is PostGIS?

Regards,

David

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Gard 2022-10-14 07:13:05 Re: Append a list of tables to an empty table to form a whole table
Previous Message Frank Gard 2022-10-13 17:17:00 Re: How to union all tables in a schema into one whole table?