需要在 psql 中以特定格式输出
Need the output in specific format in psql
假设:-
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'
使用quote_literal
该函数在给定的string/number前后添加单引号。阅读 here.
subh=# select 'test123' || ' ' || quote_literal(obj_description('test123'::regclass)) as test;
subh=# select 'test123' || ' \'' || obj_description('test123'::regclass) as test || '\'';
test
-------------------------------
test123 'this is my table'
\'
将用于添加引号
假设:-
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'
使用quote_literal
该函数在给定的string/number前后添加单引号。阅读 here.
subh=# select 'test123' || ' ' || quote_literal(obj_description('test123'::regclass)) as test;
subh=# select 'test123' || ' \'' || obj_description('test123'::regclass) as test || '\'';
test
-------------------------------
test123 'this is my table'
\'
将用于添加引号