假设:-
subh=# select 'test123';
?column?
-------------------------------------
test123
和
subh=# select obj_description('test123'::regclass);
obj_description
--------------------
this is my table
我正在运行此查询:-
subh=# select 'test123' || ' ' || obj_description('test123'::regclass) as test;
test
-------------------------------
test123 this is my table
实际上我希望输出如下:-
test
-------------------------------
test123 'this is my table'
答案 0 :(得分:0)
使用quote_literal
此函数在给定的字符串/数字的前面和后面添加单引号。阅读here。
subh=# select 'test123' || ' ' || quote_literal(obj_description('test123'::regclass)) as test;
答案 1 :(得分:-1)
subh=# select 'test123' || ' \'' || obj_description('test123'::regclass) as test || '\'';
test
-------------------------------
test123 'this is my table'
\'
将用于添加报价