pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to right justify text in psql?
3+ messages / 3 participants
[nested] [flat]

* How to right justify text in psql?
@ 2013-05-17 15:26 Brian Sherwood <bdsher@gmail.com>
  2013-05-18 04:07 ` Re: How to right justify text in psql? Jov <zhao6014@gmail.com>
  2013-05-18 05:28 ` Re: How to right justify text in psql? Ian Lawrence Barwick <barwick@gmail.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Brian Sherwood @ 2013-05-17 15:26 UTC (permalink / raw)
  To: pgsql-sql

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?


Thanks

Brian

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to right justify text in psql?
  2013-05-17 15:26 How to right justify text in psql? Brian Sherwood <bdsher@gmail.com>
@ 2013-05-18 04:07 ` Jov <zhao6014@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Jov @ 2013-05-18 04:07 UTC (permalink / raw)
  To: Brian Sherwood <bdsher@gmail.com>; +Cc: pgsql-sql

the column type info can be found in information_schema.column view.

jov
在 2013-5-17 下午11:27,"Brian Sherwood" <bdsher@gmail.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?
>
>
> Thanks
>
> Brian
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to right justify text in psql?
  2013-05-17 15:26 How to right justify text in psql? Brian Sherwood <bdsher@gmail.com>
@ 2013-05-18 05:28 ` Ian Lawrence Barwick <barwick@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Ian Lawrence Barwick @ 2013-05-18 05:28 UTC (permalink / raw)
  To: Brian Sherwood <bdsher@gmail.com>; +Cc: pgsql-sql

2013/5/18 Brian Sherwood <bdsher@gmail.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


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2013-05-18 05:28 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-05-17 15:26 How to right justify text in psql? Brian Sherwood <bdsher@gmail.com>
2013-05-18 04:07 ` Jov <zhao6014@gmail.com>
2013-05-18 05:28 ` Ian Lawrence Barwick <barwick@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox