I have two tables (in CartoDB/PostGIS) that are from two tiger shapefiles that have the exact same attributes, just in different counties. I want to combine them in to a single table, just appending the data from one to the other. What is the SQL call to do that?
1 Answer
Presuming you have two datyasets with the same attributes:
test_points1
and test_points2
you can combine them like this:
CREATE TABLE combined AS(
SELECT id, city, geom FROM test_points1
UNION
SELECT id, city, geom FROM test_points2)
and the result is the combined table:
-
1The UNION keyword will check to ensure that all records are unique (which is expensive). If you don't want then de-duped in the process, use UNION ALL instead. Feb 27, 2014 at 18:20