Reputation: 22460
I was wondering if there is a syntax to refer to a table name with minus signs in it. For example, I imported a table called v-water-a
using shp2psql
, and then did:
select * from v-water-a limit 1;
and I got an error:
ERROR: syntax error at or near "-"
LINE 1: select * from v-water-a limit 1;
The same query works if the table was named v_water_a
. Also, the table v-water-a
is visible in pgadmin3. I tried quote the name with single quotes, but it didn't work.
Should I quote the table name somehow? or is it the name illegal?
This is with PostgreSQL 9.3.5 under Ubuntu 14.04.
Upvotes: 3
Views: 3704
Reputation: 183270
Use double-quotes:
select * from "v-water-a" limit 1;
Documentation: http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html
Upvotes: 9