Search Postgresql Archives

Re: Overriding default psql behavior | how to ignore missing fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 31 December 2010 9:06:19 am Håvard Wahl Kongsgård wrote:
> Well I created the SQL files from multiple shapefiles. Used the shp2sql (
> postgis 1.5) to generate the SQL dumps.
>

And the shp2pgsql docs say:

"Appends data from the Shape file into the database table. Note that to use this 
option to load multiple files, the files must have the same attributes and same 
data types. "

The problem is just not adding/removing the field(s) from the target table but 
also maintaining field order. The inserts are assuming a set order and number 
of fields. My guess is the answer lies in using the -c option to shp2pgsql and 
have it create the tables for each file in the database. You could then move 
the fields you need to the target table. Another route would be to use the -D 
option which creates a Postgres dump format for the data i.e COPY see below for 
example:

COPY table2 (fulldate, id, meanvalue) FROM stdin;
2009-01-01 00:00:00 1 12.3
2009-01-01 01:00:00 1 11.8
2009-01-01 02:00:00 1 82.099998
2009-01-01 03:00:00 1 79.800003
2009-01-01 04:00:00 1 77.199997
2009-01-01 05:00:00 1 13.1

You could probably use that and a script to feed the data to your target.



-- 
Adrian Klaver
adrian.klaver@xxxxxxxxx

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux