Re: Append a list of tables to an empty table to form a whole table
От | Frank Gard |
---|---|
Тема | Re: Append a list of tables to an empty table to form a whole table |
Дата | |
Msg-id | d4468415-90b4-7560-849b-d35acc94de56@familie-gard.de обсуждение исходный текст |
Ответ на | Append a list of tables to an empty table to form a whole table (Shaozhong SHI <shishaozhong@gmail.com>) |
Ответы |
Re: Append a list of tables to an empty table to form a whole table
|
Список | pgsql-sql |
Hi,
again: Use EXECUTE! It's well documented here: https://www.postgresql.org/docs/15/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
In your case, you can simply replace your INSERT statement by the following:
EXECUTE 'insert into em_table as select * from table ' || a_name;
Hope this helps.
Frank.
Am 14.10.22 um 08:00 schrieb Shaozhong SHI:
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 columstable_atable_btable_cCreate an empty table emp_tableForeach a_name in ARRAY ARRAY['table_a', 'table_b', 'table_c'] loopinsert into em_table as select * from table a_nameend loop;Can something like that be done is PostGIS?Regards,David
-- Vielen Dank und viele Grüße, Frank Gard Zum Brünnchen 27 D-66583 Spiesen-Elversberg Tel. : +49(6821)790880 E-Mail: frank@familie-gard.de Bitte denken Sie über Ihre Verantwortung gegenüber der Umwelt nach, bevor Sie diese Mail ausdrucken. Bitte senden Sie mir keine Word-, Excel- oder PowerPoint-Anhänge. Siehe http://www.gnu.org/philosophy/no-word-attachments.de.html GnuPG / PGP info ================ Schlüssel-ID: 0xC8C1A552 Fingerabdruck / fingerprint: 3EFD EF94 4841 38B5 DB40 95D8 C69C 71C5 C8C1 A552
В списке pgsql-sql по дате отправления: