Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Might be this: <a href="http://www.sqlfiddle.com/#!1/d41d8/364" rel="noreferrer">http://www.sqlfiddle.com/#!1/d41d8/364</a></p> <pre><code>select translate(string_to_array(x.*::text,',')::text,'()','')::text[] from pg_tables as x </code></pre> <p>How it works (inside-out), 5 steps:</p> <p>1st:</p> <pre><code>select x.*::text from pg_tables as x; </code></pre> <p>Sample Output:</p> <pre><code>| X | ---------------------------------------------------------------- | (pg_catalog,pg_statistic,postgres,,t,f,f) | | (pg_catalog,pg_type,postgres,,t,f,f) | </code></pre> <p>2nd:</p> <pre><code>select string_to_array(x.*::text,',') from pg_tables as x; </code></pre> <p>Sample Output:</p> <pre><code>| STRING_TO_ARRAY | --------------------------------------------- | (pg_catalog,pg_statistic,postgres,,t,f,f) | | (pg_catalog,pg_type,postgres,,t,f,f) | </code></pre> <p>3rd:</p> <pre><code>select string_to_array(x.*::text,',')::text from pg_tables as x; </code></pre> <p>Sample Output:</p> <pre><code>| STRING_TO_ARRAY | ------------------------------------------------- | {(pg_catalog,pg_statistic,postgres,"",t,f,f)} | | {(pg_catalog,pg_type,postgres,"",t,f,f)} | </code></pre> <p>4th:</p> <pre><code>select translate( string_to_array(x.*::text,',')::text, '()', '') from pg_tables as x </code></pre> <p>Sample Output:</p> <pre><code>| TRANSLATE | ----------------------------------------------- | {pg_catalog,pg_statistic,postgres,"",t,f,f} | | {pg_catalog,pg_type,postgres,"",t,f,f} | </code></pre> <p>Finally:</p> <pre><code>select translate( string_to_array(x.*::text,',')::text, '()', '')::text[] from pg_tables as x </code></pre> <p>Sample Output:</p> <pre><code>| TRANSLATE | ------------------------------------------- | pg_catalog,pg_statistic,postgres,,t,f,f | | pg_catalog,pg_type,postgres,,t,f,f | </code></pre> <p>Live test: <a href="http://www.sqlfiddle.com/#!1/d41d8/373" rel="noreferrer">http://www.sqlfiddle.com/#!1/d41d8/373</a></p> <p>To prove that it works:</p> <pre><code>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; </code></pre> <p>Sample output:</p> <pre><code>| 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 | </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload