Tuesday 1 April 2014

psql - expanded mode

I was looking at some postgresql tables trying to diagnose a problem, the amount of data in the table was making it difficult to see the separate records and not being familiar with what data I needed I could not just select the columns I was interested in.

I had see someone produce some output from a similar table where it was clearer laying out the records and so I was curious how this could be achieved a quick search through the docs mentioned "expanded mode". This can be enabled using

\x on


This gives the output to queries in the following format

select * from random_table;
-[ Record 1 ]------+------------------------------------------
column_1   | some data
column_2   | some other data
-[ Record 2 ]------+------------------------------------------
column_1   | some data 2
column_2   | some other data 2
--------------------------------------------------------------


This was much clearer for me to see what was going on on the terminal.