postgresql:hstore 键作为保留关键字:有什么办法吗?
postgresql : hstore key as a reserved keyword : any way around?
使用 Postgresql 9.4
我有一个 table,其中的 hstore 字段名为 'references' :
尝试做:select * 来自 table where (references -> 'key' = 'value')
结果
ERROR: syntax error at or near "references"
因为它与另一个字段名一起按预期工作,我怀疑这是因为它是一个保留字...但我不想在我的应用程序中重命名这个频繁使用的字段。
那么,有什么语法可以解决这个问题吗?
您需要将作为关键字的列名用双引号引起来。
所以,感谢 David,解决方案是:
select * from table where ( "references"->'key' = 'value' );
引号和双引号的含义很重要。
使用 Postgresql 9.4
我有一个 table,其中的 hstore 字段名为 'references' :
尝试做:select * 来自 table where (references -> 'key' = 'value') 结果
ERROR: syntax error at or near "references"
因为它与另一个字段名一起按预期工作,我怀疑这是因为它是一个保留字...但我不想在我的应用程序中重命名这个频繁使用的字段。
那么,有什么语法可以解决这个问题吗?
您需要将作为关键字的列名用双引号引起来。
所以,感谢 David,解决方案是:
select * from table where ( "references"->'key' = 'value' );
引号和双引号的含义很重要。