SHP2PGSQL 创建一个表,但 Psql 报告"relation...does not exist"



使用shp2pgsql将形状文件导入PostGIS数据库,一切都很好:

Connection: host=localhost port=5432 user=aperrin dbname=tweets password='******' 
Destination: public.County_2010Census_DP1
Source File: /home/aperrin/Downloads/County_2010Census_DP1/County_2010Census_DP1
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
Importing shapefile (3221 records)...
Creating spatial index...
Shapefile import completed.

在psql中,\d显示:

                          List of relations
 Schema |                  Name                   |   Type   |  Owner   
--------+-----------------------------------------+----------+----------
 public | County_2010Census_DP1                   | table    | aperrin
 public | County_2010Census_DP1_gid_seq           | sequence | aperrin

但是:

tweets=> d County_2010Census_DP1
Did not find any relation named "County_2010Census_DP1".
tweets=> select * from County_2010Census_DP1;
ERROR:  relation "county_2010census_dp1" does not exist
LINE 1: select * from County_2010Census_DP1;

使用全小写的表名解决了这个问题。使用us_counches作为表名。

使用大写表名时可以使用双引号。

   select * from "County_2010Census_DP1";

您可能需要使用以下代码向数据库添加postgis扩展:

psql -U username -d databasename
CREATE EXTENSION postgis;

最新更新