STV_ShpCreateTable

Returns a CREATE TABLE statement with the columns and types of the attributes found in the specified shapefile.

The column types are sized according to the shapefile metadata. The size of the column is based on the largest geometry found in the shapefile. The first column in the table is gid, which is an auto-increment IDENTITY primary key column. The cache value is set to 64 by default. The last column is a GEOMETRY data type for storing the actual geometry data.

Behavior Type

Immutable

Syntax

STV_ShpCreateTable(USING PARAMETERS file='filename') OVER()

Arguments

file = 'filename'

Fully qualified path of the .dbf, .shp, or .shx file. (The extension is optional.)

Returns

CREATE TABLE statement that matches the specified shapefile

Usage Tips

Example

The following example shows how to use STV_ShpCreateTable.

Returns a CREATE TABLE statement:

=> SELECT STV_ShpCreateTable
      (USING PARAMETERS file='/shapefiles/tl_2010_us_state10.shp')
      OVER() as create_table_states;
      create_table_states      
 ----------------------------------
CREATE TABLE tl_2010_us_state10(
   gid IDENTITY(64) PRIMARY KEY, 
   REGION10 VARCHAR(2), 
   DIVISION10 VARCHAR(2), 
   STATEFP10 VARCHAR(2),
   STATENS10 VARCHAR(8),
   GEOID10 VARCHAR(2),
   STUSPS10 VARCHAR(2),
   NAME10 VARCHAR(100),
   LSAD10 VARCHAR(2),
   MTFCC10 VARCHAR(5),
   FUNCSTAT10 VARCHAR(1),
   ALAND10 INT8,
   AWATER10 INT8,
   INTPTLAT10 VARCHAR(11),
   INTPTLON10 VARCHAR(12), 
   geom GEOMETRY(940845) 
);
(18 rows)