The db2se import_shape command imports a shape file to a database that is enabled for spatial operations.
This command can import shape and attribute data into an existing table or a new table.
The DB2® instance owner ID must have the necessary privileges on the DB2 server to create or write to the exception and messages files.
db2se import_shape command >>-import_shape--database_name----------------------------------> >--+------------------------------------+-----------------------> '- -userId--user_id-- -pw--password -' >-- -fileName--file_name----------------------------------------> >--+-------------------------------------+----------------------> '- -inputColumnNames--input_col_names-' >-- -srsName--srs_name--+-----------------------------+---------> '- -tableSchema--table_schema-' >-- -tableName--table_name--------------------------------------> >--+----------------------------------+-------------------------> '- -tableAttrColumns--attr_columns-' >--+--------------------------------+---------------------------> '- -createTableFlag--create_flag-' >--+------------------------------------------+-----------------> '- -tableCreationParameters--tc_parameters-' >-- -spatialColumn--spatial_column------------------------------> >--+---------------------------+--+-----------------------+-----> '- -typeSchema--type_schema-' '- -typeName--type_name-' >--+---------------------------+--+-----------------------+-----> '- -inlineLength--in_length-' '- -idColumn--id_column-' >--+-------------------------------+----------------------------> '- -idColumnIsIdentity--id_flag-' >--+--------------------------+---------------------------------> '- -restartCount--rs_count-' >--+-----------------------------+------------------------------> '- -commitScope--commit_count-' >--+------------------------------+-----------------------------> '- -exceptionFile--e_file_name-' >--+-------------------------------+----------------------------> '- -messagesFile--msg_file_name-' >--+-----------------------+----------------------------------->< '- -client--client_flag-'
The maximum length for this parameter is 256 characters.
N(COLUMN1,COLUMN5,COLUMN3,COLUMN7)
If the column names are not enclosed in double quotation marks, the column names are converted to uppercase. The resulting names must exactly match the column names in the dBASE file.
P(1,5,3,7)
Columns
are numbered beginning with 1. Each number in the list must be separated
by a comma. The maximum length for this parameter is 32,672 characters.
The spatial column is not registered. The SRS must exist before the data is imported. The import process does not implicitly create the SRS, but it does compare the coordinate system of the SRS with the coordinate system that is specified in the .prj file (if this file is available with the shape file).
The import process also verifies that the extents of the data in the shape file can be represented in the specified SRS. That is, the import process verifies that the extents lie within the minimum and maximum X, Y, Z, and M coordinates of the SRS.
The number of specified columns must match the number of columns to be imported from the dBASE file. If the table exists, the column definitions must match the incoming data. See Usage notes for an explanation of how attribute data types are mapped to DB2 data types.
If the column names are not enclosed in double quotation marks, the column names are converted to uppercase. The maximum length for this parameter is 32,672 characters.
If this parameter is not specified, a new table is created.
IN tsName INDEX IN indexTsName LONG IN longTsName
The maximum length for this parameter is 32,672 characters.
For a new table, this parameter specifies the name of the new spatial column that is to be created. For an existing table, this parameter specifies the name of an existing spatial column in the table.
The spatial_column value is converted to uppercase unless you enclose it in double quotation marks.
The type_schema value is converted to uppercase unless you enclose it in double quotation marks.
Shape files, by definition, allow a distinction only between points and multipoints. There is no distinction between polygons and multipolygons or between linestrings and multilinestrings.
If you are importing into a new table, type_name data type is also used for the data type of the spatial column. In this case, the data type can also be a super type of ST_Point, ST_MultiPoint, ST_MultiLineString, or ST_MultiPolygon.
The type_name value is converted to uppercase unless you enclose it in double quotation marks.
Spatial records that exceed the inline_length size are stored separately in the LOB table space, which might be slower to access.
For a complete description of the inline_length value, see the CREATE TABLE statement in the DB2 documentation. Use the ADMIN_EST_INLINE_LENGTH table function to help you estimate the inline length required for geometries in existing tables.
INTEGER NOT NULL PRIMARY KEY
If id_column_is_identity has
a non-zero value, the definition is expanded as follows: INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY
( START WITH 1 INCREMENT BY 1 )
The id_column value is converted to uppercase unless you enclose it in double quotation marks.
If you specify a value for the parameter and include an optional file extension, specify either .shp or .SHP. If the extension you do not specify an extention, the .shp extension is appended to exception_file.
The exception file contains the complete set of rows for the insert statement that failed. One insert statement can add a multiple number of rows. For example, assume that one row cannot be imported because the shape data is incorrectly encoded. A single insert statement attempts to import 20 rows, including the one with incorrect shape data. Because the insert statement fails, the entire set of 20 rows is written to the exception file.
Records that are written to the exception file only when those records can be correctly identified, as is the case when the shape record type is not valid. Some types of corruption to the shape data (.shp files) and shape index (.shx files) do not allow the appropriate records to be identified. In this case, records cannot be written to the exception file, and an error message is issued to report the problem.
If you specify a value for this parameter, four files are created on the DB2 server. See Usage notes for an explanation these files.
If the exception_file file already exists, the command returns an error.
The maximum length for this parameter is 256 characters.
If the msg_file_name file already exists, the command returns an error.
The maximum length for this parameter is 256 characters.
If you do not specify this parameter, the 0 value is the default.
You can perform the import process on the client where the command is executed. This is often more convenient as it does not require access to the DB2 server file system.
.dbf type | .dbf length1 | .dbf decimals 2 | SQL type | Comments |
---|---|---|---|---|
N | < 5 | 0 | SMALLINT | |
N | < 10 | 0 | INTEGER | |
N | < 20 | 0 | BIGINT | |
N | len | dec | DECIMAL(len,dec) | len<32 |
F | len | dec | REAL | len + dec < 7 |
F | len | dec | DOUBLE | |
C | len | CHAR(len) | ||
L | CHAR(1) | |||
D | DATE |
For example, assume that the dBASE file contains a column of data whose length (len) is defined as 20. Assume that the number of digits to the right of the decimal point (dec) is defined as 5. When DB2 Spatial Extender imports data from that column, it uses the values of len and dec to derive the following SQL data type: DECIMAL(20,5).
db2se import_shape mydb -fileName myfile -srsName NAD83_SRS_1
-tableName mytable -spatialColumnName mycolumn -client 1