hstore值与空间

时间:2013-07-30 00:24:27

标签: postgresql space hstore

我正在使用Postgresql V 9.1:

SELECT 'k=>name, v=>Nava Ratna Secondary School'::hstore;

此代码返回错误:

ERROR:  Syntax error near 'R' at position 17
LINE 1: SELECT 'k=>name, v=>Nava Ratna Secondary School'::hstore;
               ^

********** Error **********

ERROR: Syntax error near 'R' at position 17
SQL state: XX000
Character: 8

将'Nava Ratna Secondary School'中的空间填充为'Nava_Ratna_Secondary_School'或将其删除'NavaRatnaSecondarySchool'作品。

但我需要存放v = Nava Ratna中学的空格。怎么做?

1 个答案:

答案 0 :(得分:1)

SELECT 'k=>name, v=>"Nava Ratna Secondary School"'::hstore;

当值或键中有单引号时,最简单的方法是使用美元引用:

SELECT $$k=>"name", v=>"St. Xavier's Academy"$$::hstore;

或更广泛的逃避:

SELECT 'k=>"name", v=>"St. Xavier''s Academy"'::hstore;