postgres如何用减号引用表名 [英] postgres how to refer to table names with minus signs
问题描述
我想知道是否存在引用带有减号的表名的语法。例如,我使用 shp2psql
导入了名为 v-water-a
的表,然后执行了以下操作:
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;
我收到一个错误:
ERROR: syntax error at or near "-"
LINE 1: select * from v-water-a limit 1;
如果表名为 v_water_a $ c $,则该查询有效c>。此外,表
v-water-a
在pgadmin3中可见。我试过用单引号将名称引起来,但没有用。
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.
我应该以某种方式对表名加引号吗?
这是Ubuntu 14.04下的PostgreSQL 9.3.5。
Should I quote the table name somehow? or is it the name illegal?
This is with PostgreSQL 9.3.5 under Ubuntu 14.04.
推荐答案
使用双引号:
select * from "v-water-a" limit 1;
文档: http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html
这篇关于postgres如何用减号引用表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!