【发布时间】:2014-11-10 08:42:21
【问题描述】:
我在数据库中有一个表query_config,其中将包含用于查询的脚本,以及其他配置值。这就是我使用 json 类型的原因。 如下表:
CREATE TABLE query_config
(
id integer,
execute_query json
);
在这个表中我想插入例如:
INSERT INTO query_config(id, execute_query)
VALUES (4, ('{"query": ' ||
'"select *
from tests
where tests.id > 5
order by moment desc"}')::json);
但我不断收到错误:
ERROR: invalid input syntax for type json
DETAIL: Character with value 0x0a must be escaped.
请问我做错了什么以及如何转义换行符?
【问题讨论】:
标签: json postgresql type-conversion