列名称问题在PostgreSQL中包含冒号 [英] Problem with a column name contains a colon in PostgreSQL
问题描述
我从OSM下载了形状数据. 我已经将数据从Shapefile导入PostgreSQL了,没有任何问题,但是在执行select语句时出现了错误.
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 ":"
问题是因为列名包含冒号. 有人可以帮我解决这个问题吗? 我应该在导入过程中拒绝此shapefile吗? shapefile是否正常?
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?
推荐答案
如果用引号将addr:city
括起来,它应该可以工作:
If you enclose addr:city
with quotes it should work:
SELECT "addr:city" FROM "location";
如果要使用OpenStreetMap数据,则不必导入shapefile.相反,您可以直接使用 osm2pgsql 导入planet.osm(或区域子集).
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.
这篇关于列名称问题在PostgreSQL中包含冒号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!