我試圖導入空間文件到我的數據庫錯誤:功能addgeometrycolumn(未知..),到PostGIS的數據庫中插入SQL文件時
首先,我創建了使用postgis template
數據庫如下
createdb -T template_postgis database_name;
我已經安裝在我的機器上的PostGIS
POSTGIS="2.1.1 r12113" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.0, released 2011/12/29" LIBXML="2.7.8" LIBJSON="UNKNOWN" TOPOLOGY RASTER
Postgres的版本:psql (9.3.2, server 9.1.11)
其次我已經轉換空間文件中的sql文件,如下
shp2pgsql -s 3425 Aspire.shp test_for_shape_data database_name > shapefile_data.sql
,現在我想在這個SQL文件(shapefile_data.sql)導入到我的數據庫(數據庫名稱)像下面
psql -d database_name username -f shapefile_data.sql
但我收到以下錯誤
[email protected]:~/user/spice$ psql -d psql -d database_name username -f shapefile_data.sql
SET
SET
BEGIN
psql:shapefile_data.sql:30: NOTICE: CREATE TABLE will create implicit sequence "test_for_shape_data_gid_seq" for serial column "test_for_shape_data.gid"
CREATE TABLE
psql:shapefile_data.sql:31: NOTICE: ALTER TABLE/ADD PRIMARY KEY will create implicit index "test_for_shape_data_pkey" for table "test_for_shape_data"
ALTER TABLE
psql:shapefile_data.sql:32: ERROR: function addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) is not unique
LINE 1: SELECT AddGeometryColumn('','test_for_shape_data','geom','42...
^
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
psql:shapefile_data.sql:33: ERROR: current transaction is aborted, commands ignored until end of transaction block
psql:shapefile_data.sql:34: ERROR: current transaction is aborted, commands ignored until end of transaction block
...........
.......
爲什麼它是告訴我,我沒有AddGeometryColumn
函數,即使我已創建數據庫與postgis template
?
那麼如何避免這種情況呢?
而且當我嘗試手動啓用PostGIS的功能已經存在
database_name=# CREATE EXTENSION postgis;
ERROR: type "spheroid" already exists
database_name=# CREATE EXTENSION postgis_topology;
ERROR: required extension "postgis" is not installed
那麼如何清除這個錯誤,並在數據庫中插入shape文件SQL文件的說服力?