यह हो सकता है:http://www.sqlfiddle.com/#!1/d41d8 /364
select translate(string_to_array(x.*::text,',')::text,'()','')::text[]
from pg_tables as x
यह कैसे काम करता है (अंदर-बाहर), 5 कदम:
पहला:
select x.*::text from pg_tables as x;
नमूना आउटपुट:
| X |
----------------------------------------------------------------
| (pg_catalog,pg_statistic,postgres,,t,f,f) |
| (pg_catalog,pg_type,postgres,,t,f,f) |
दूसरा:
select string_to_array(x.*::text,',') from pg_tables as x;
नमूना आउटपुट:
| STRING_TO_ARRAY |
---------------------------------------------
| (pg_catalog,pg_statistic,postgres,,t,f,f) |
| (pg_catalog,pg_type,postgres,,t,f,f) |
तीसरा:
select string_to_array(x.*::text,',')::text from pg_tables as x;
नमूना आउटपुट:
| STRING_TO_ARRAY |
-------------------------------------------------
| {(pg_catalog,pg_statistic,postgres,"",t,f,f)} |
| {(pg_catalog,pg_type,postgres,"",t,f,f)} |
चौथा:
select translate( string_to_array(x.*::text,',')::text, '()', '') from pg_tables as x
नमूना आउटपुट:
| TRANSLATE |
-----------------------------------------------
| {pg_catalog,pg_statistic,postgres,"",t,f,f} |
| {pg_catalog,pg_type,postgres,"",t,f,f} |
अंत में:
select translate( string_to_array(x.*::text,',')::text, '()', '')::text[]
from pg_tables as x
नमूना आउटपुट:
| TRANSLATE |
-------------------------------------------
| pg_catalog,pg_statistic,postgres,,t,f,f |
| pg_catalog,pg_type,postgres,,t,f,f |
लाइव परीक्षण:http://www.sqlfiddle.com/#!1/d41d8/ 373
यह साबित करने के लिए कि यह काम करता है:
with a as
(
select translate( string_to_array(x.*::text,',')::text, '()', '')::text[] as colArray
from pg_tables as x
)
select row_number() over(), unnest(colArray)
from a;
नमूना आउटपुट:
| ROW_NUMBER | UNNEST |
----------------------------------------
| 1 | pg_catalog |
| 1 | pg_statistic |
| 1 | postgres |
| 1 | |
| 1 | t |
| 1 | f |
| 1 | f |
| 2 | pg_catalog |
| 2 | pg_type |
| 2 | postgres |
| 2 | |
| 2 | t |
| 2 | f |
| 2 | f |