10

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?

2
  • SELECT 'addr:city' FROM location might do the trick Commented Feb 9, 2011 at 3:20
  • @Nick : This would select the string 'addr:city', not the column. You want to use double quote in this case. Commented Feb 9, 2011 at 4:06

1 Answer 1

15

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.