<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>David, this is a list for Post<b>GIS </b>related questions. Your
question is strictly Post<b>Gres</b> related. <br>
</p>
<p>However, you can use the following SQL commands:</p>
<p><font face="monospace">-- Create new empty table with the same
columns/types as "table_a".<br>
CREATE TABLE new_table (LIKE table_a);<br>
</font></p>
<p><font face="monospace">-- Create primary key constraint and index
on geometry<br>
ALTER TABLE new_table ADD PRIMARY KEY (your_pk_column); --
change to relevant column name<br>
CREATE INDEX ON new_table USING GIST (your_geom_column); </font><font
face="monospace">-- change to relevant column name</font><font
face="monospace"></font></p>
<p><font face="monospace">-- Insert rows from 3 tables with the same
structure into table "new_table"<br>
INSERT INTO new_table SELECT * FROM table_a;<br>
<br>
</font><font face="monospace"><font face="monospace">-- Will only
work if there is no overlap on primary key values in the 3
tables<br>
</font>INSERT INTO new_table SELECT * FROM table_b;<br>
INSERT INTO new_table SELECT * FROM table_c;<br>
</font></p>
<pre class="moz-signature" cols="72">Best regards
Bo Victor Thomsen, Ms.Sc.Eng
aestasGIS Denmark
<b style="color: rgb(32, 33, 34); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
</b></pre>
<div class="moz-cite-prefix">Den 14-10-2022 kl. 07:59 skrev
Shaozhong SHI:<br>
</div>
<blockquote type="cite"
cite="mid:CA+i5JwYX9jDXv2fS9u6JP24=xpaTX_r6SXMjUCg5JGwTA2cPog@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">How best to append a list of tables to an empty
table to form a whole table?
<div><br>
</div>
<div>Pseudo codes show the desirable logic.</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div><br>
</div>
<div>There are a list of tables with exactly same colums</div>
<div>table_a</div>
<div>table_b</div>
<div>table_c</div>
<div><br>
</div>
<div>Create an empty table emp_table</div>
<div><br>
</div>
<div>Foreach a_name in ARRAY ARRAY['table_a', 'table_b',
'table_c'] loop</div>
<div> insert into em_table as select * from table a_name</div>
<div><br>
</div>
<div>end loop;</div>
</div>
<div><br>
</div>
<div>Can something like that be done is PostGIS?</div>
<div><br>
</div>
<div>Regards,</div>
<div><br>
</div>
<div>David</div>
</div>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/postgis-users">https://lists.osgeo.org/mailman/listinfo/postgis-users</a>
</pre>
</blockquote>
</body>
</html>