[postgis-users] Appending geometry data from another table

Michael Fuhr mike at fuhr.org
Fri Oct 20 18:24:15 PDT 2006


On Fri, Oct 20, 2006 at 11:33:57AM -0600, Bruce Rindahl wrote:
> I have an existing table that I want to append new data from another table.
> I can't figure out how to append the geometry.  My query looks something
> like this:
> 
> INSERT into county_parcels SELECT
> 'Archuleta' as county,
> the_geom as the_geom
>  FROM county_temp;
> 
> The error is:
> 
> ERROR:  column "the_geom" is of type geometry but expression is of type
> character varying

Since the INSERT doesn't specify a column list, make sure the first
two columns in county_parcels match the types of the corresponding
columns in the SELECT.  The error suggests that county_temp.the_geom
is a varchar, not a geometry; if so then you could use a constructor
like GeomFromText or GeomFromEWKT to convert the varchar to a geometry.
For example:

INSERT INTO county_parcels
SELECT 'Archuleta', GeomFromText(the_geom)
FROM county_temp;

-- 
Michael Fuhr



More information about the postgis-users mailing list