Wednesday, February 4, 2015

Simple multicolumn ouput in psql

There are interesting idea on Depesz's blog .

But some possibility has a Linux itself. There is simple pager column.

You can try (blogger engine break formatting):
postgres=# \pset tuples_only
postgres=# \setenv PAGER column

postgres=# select typname from pg_type limit 100;
 bool   pg_type  line   _bool   _varchar  _inet   _numeric
 bytea   pg_attribute  _line   _bytea   _int8   _cidr   timetz
 char   pg_proc  float4   _char   _point   _cstring  _timetz
 name   pg_class  float8   _name   _lseg   bpchar   bit
 int8   json   abstime  _int2   _path   varchar  _bit
 int2   xml   reltime  _int2vector  _box   date   varbit
 int2vector  _xml   tinterval  _int4   _float4  time   _varbit
 int4   _json   unknown  _regproc  _float8  timestamp  numeric
 regproc  pg_node_tree  circle   _text   _abstime  _timestamp  refcursor
 text   smgr   _circle  _oid   _reltime  _date   _refcursor
 oid   point   money   _tid   _tinterval  _time
 tid   lseg   _money   _xid   _polygon  timestamptz
 xid   path   macaddr  _cid   aclitem  _timestamptz
 cid   box   inet   _oidvector  _aclitem  interval
 oidvector  polygon  cidr   _bpchar  _macaddr  _interval

postgres=# 
It works together with less
postgres=# \setenv PAGER '(column | less)'
postgres=# select typname from pg_type;
 ...

Do you know some other nice pagers?

3 Comments:

At February 4, 2015 at 11:28 AM , Anonymous depesz said...

Well, it will not work as nicely with more complex values (like with spaces). Not to mention, that it's not really properly formatted. Would much prefer native psql solution...

 
At February 4, 2015 at 11:40 AM , Blogger Pavel Stěhule said...

@Depesz: It was a first time when I used a "column" pager. It was just a game, nothing more

 
At February 4, 2015 at 11:49 AM , Blogger Pavel Stěhule said...

and linux "column" pager is enough just only for very simple layout.

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home