Problem with a column name contains a colon in PostgreSQL

空扰寡人 提交于 2019-12-08 16:39:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!