Re: How to right justify text in psql?

From: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
To: Brian Sherwood <bdsher(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to right justify text in psql?
Date: 2013-05-18 05:28:01
Message-ID: CAB8KJ=hQ+m-dStL6NQm1-phjPX1cZ9TMVqgKORGAA=6SeL+4Dg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

2013/5/18 Brian Sherwood <bdsher(at)gmail(dot)com>:
> I am running postgresql 9.2.
>
> I am assuming it would be a function of psql to right justify text, but I
> can't find any way to do this.
>
> Is there a way to right justify just one text column?

If you mean have the psql client right-justify a particular text column, no I
don't think there's a way to do that.

Assuming the column contains single-width characters with no line breaks,
you could do something with LPAD along these lines:

SELECT LPAD(txtcol, (SELECT MAX(LENGTH(txtcol)) FROM tbl)) FROM tbl

HTH

Ian Barwick

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message JORGE MALDONADO 2013-05-23 18:10:57 Select statement with except clause
Previous Message Jov 2013-05-18 04:07:42 Re: How to right justify text in psql?