[postgis-users] How to update (replace) a Postgis table?
Francois Hugues
hugues.francois at irstea.fr
Fri Feb 8 01:36:52 PST 2013
Hello,
I think the reason why your renaming does not work comes from your
index. If you want to use the renaming strategy you may have two
strategies :
- use alter index after altertable to rename
- import with shp2pgsql without -I option and create the index on the
new populated table with a different index name
To use the -d option as suggested by paolo, you can make a backup withe
create table as xxx_original as select * from xxx (but this table will
not be indexed so to keep constraints on the table you'd better renaming
/ drop existing index)
Hugues.
-----Original Message-----
From: postgis-users-bounces at lists.osgeo.org
[mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Paolo Corti
Sent: Friday, February 08, 2013 9:15 AM
To: PostGIS Users Discussion
Cc: PostGIS Users Discussion
Subject: Re: [postgis-users] How to update (replace) a Postgis table?
On Fri, Feb 8, 2013 at 7:34 AM, Stefan Schwarzer
<stefan.schwarzer at unep.org> wrote:
> Hi there,
>
> I would like to "update" a "countries of the world"-postgis-table, by
> replacing it with another one which comes in form of a shapefile
> (dumped from a Postgis database) from my development server.
>
> Now, I can't just do a "pgsql2shp", as this would throw an error as
> the table already exists. And renaming the existing table into
> something like "xx_original" doesn't work either ("xx_geom_gist
> already exists", is then the error message).
>
> I don't want to delete the (old) table directly, as I would like to
> keep it as a backup.
>
> So, what is the "right" way to solve this? Thanks for any hints!
>
Using the pgsql2shp -d option will drop and recreate the table regards
--
Paolo Corti
Geospatial software developer
web: http://www.paolocorti.net
twitter: @capooti
skype: capooti
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list