gpt4 book ai didi

postgresql - hstore 带空格的值

转载 作者:行者123 更新时间:2023-11-29 13:33:47 26 4
gpt4 key购买 nike

我正在使用 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 Secondary School。怎么做?

最佳答案

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;

关于postgresql - hstore 带空格的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17936417/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com