\fB\-c\fR
Creates a new table and populates it from the Shape file. This is the default mode.
+.TP
+\fB\-p\fR
+Only produces the table creation SQL code, without adding any actual data. This can
+be used if you need to completely separate the table creation and data loading steps.
+
.TP
\fB\-D\fR
-Use the PostgreSQL "dump" format for the output data. This can be combined with -d, -a and -c and is much faster to load than the default "insert" SQL format. Use this for very large data sets.
+Use the PostgreSQL "dump" format for the output data. This can be combined with -a, -c and -d.
+It is much faster to load than the default "insert" SQL format. Use this for very large data sets.
.TP
\fB\-s\fR <\fISRID\fR>
Note that this will introduce coordinate drifts and will drop
M values from shapefiles.
+.LP
+Note that -a, -c, -d and -p are mutually exclusive.
+
.SH "EXAMPLES"
.LP
An example session using the loader to create an input file and uploading it might look like this:
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>-p</term>
+
+ <listitem>
+ <para>Only produces the table creation SQL code, without adding
+ any actual data. This can be used if you need to completely
+ separate the table creation and data loading steps.</para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>-D</term>
<listitem>
- <para>Creates a new table and populates it from the Shape file.
- This uses the PostgreSQL "dump" format for the output data and
- is much faster to load than the default "insert" SQL format. Use
- this for very large data sets.</para>
+ <para>Use the PostgreSQL "dump" format for the output data. This
+ can be combined with -a, -c and -d. It is much faster to load
+ than the default "insert" SQL format. Use this for very large data
+ sets.</para>
</listitem>
</varlistentry>
</variablelist>
+ <para>Note that -a, -c, -d and -p are mutually exclusive.</para>
+
<para>An example session using the loader to create an input file and
uploading it might look like this:</para>
The options are as follows:
-(-a || -c || -d) these options are mutually exclusive.
+(-a || -c || -d || -p) these options are mutually exclusive.
-a Append mode. Do not delete the target table or try to create
a new table, simple insert the data into the existing table.
A table will have to exist for this to work, it is usually
- used after a create mode as been run once.(mutually exclusive
- with -c and -d)
+ used after a create mode as been run once or after -p. (mutually
+ exclusive with -c, -d and -p)
-c Create mode. This is the default mode is no other is specified.
Create a new table and upload the data into that table.
- (mutually exclusive with -a and -d)
+ (mutually eclusive with -a, -d and -p)
-d Delete mode. Delete the database table named <tablename>, then
create a new one with that name before uploading the data into
- the new empty database table.(mutually exclusive with -a and -c)
+ the new empty database table. (mutually exclusive with -a, -c
+ and -p)
+ -p Prepare mode. Read the table schema from the shape file and
+ create the new table, but do not insert any data. (mutually
+ exclusive with -a, -c and -d)
-D Dump. When inserting the data into the table use 'dump' format.
Dump format is used by PostgreSQL for large data dumps and
/*
* Generate INSERT or COPY lines
*/
- LoadData();
+ if(opt != 'p') LoadData();
/*
* If not in 'append' mode update sequence numbering
*/
- if(opt != 'a') UpdateSerials();
+ if(opt != 'a' && opt != 'p') UpdateSerials();
printf("END;\n"); // End the last transaction
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, " -s <srid> Set the SRID field. If not specified it defaults to -1.\n");
fprintf(stderr, "\n");
- fprintf(stderr, " (-d|a|c) These are mutually exclusive options:\n");
+ fprintf(stderr, " (-d|a|c|p) These are mutually exclusive options:\n");
fprintf(stderr, " -d Drops the table , then recreates it and populates\n");
fprintf(stderr, " it with current shape file data.\n");
fprintf(stderr, " -a Appends shape file into current table, must be\n");
fprintf(stderr, " exactly the same table schema.\n");
fprintf(stderr, " -c Creates a new table and populates it, this is the\n");
fprintf(stderr, " default if you do not specify any options.\n");
+ fprintf(stderr, " -p Prepare mode, only creates the table\n");
fprintf(stderr, "\n");
fprintf(stderr, " -g <geometry_column> Specify the name of the geometry column\n");
fprintf(stderr, " (mostly useful in append mode).\n");
extern char *optarg;
extern int optind;
- while ((c = getopt(ARGC, ARGV, "kcdaDs:g:iW:w")) != EOF){
+ while ((c = getopt(ARGC, ARGV, "kcdapDs:g:iW:w")) != EOF){
switch (c) {
case 'c':
if (opt == ' ')
else
return 0;
break;
+ case 'p':
+ if (opt == ' ')
+ opt ='p';
+ else
+ return 0;
+ break;
case 'D':
dump_format =1;
break;
/**********************************************************************
* $Log$
+ * Revision 1.86 2005/04/06 14:02:08 mschaber
+ * added -p option (prepare mode) that spits out the table schema without
+ * inserting any data.
+ *
* Revision 1.85 2005/04/06 10:46:10 strk
* Bugfix in -w (hwgeom) handling of ZM shapefiles.
* Big reorganizzation of code to easy maintainance.