问题
I downloaded the shape data from OSM. I have imported data from Shapefile into PostgreSQL without any problem but I got an error when I do the select statement.
Select addr:city From location;
Error: syntax error at or near ":"
The problem is because of the column name contains a colon. Could anyone help me with this issue? Should I reject this shapefile in the importing process? Is the shapefile normal?
回答1:
If you enclose addr:city
with quotes it should work:
SELECT "addr:city" FROM "location";
And if you want to use OpenStreetMap data, you don't have to import shapefiles. Instead, you can import planet.osm (or a regional subset) directly with osm2pgsql.
来源:https://stackoverflow.com/questions/4940959/problem-with-a-column-name-contains-a-colon-in-postgresql