Re: Can psql show the column type of a result ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nils O(dot) Selåsdal" <noselasd(at)asgaard(dot)homelinux(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Can psql show the column type of a result ?
Date: 2010-09-22 21:51:25
Message-ID: 2587.1285192285@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?UTF-8?B?Ik5pbHMgTy4gU2Vsw6VzZGFsIg==?= <noselasd(at)asgaard(dot)homelinux(dot)org> writes:
> I'm wondering if there's a way to show the column type of a result with
> psql, e.g.

>>> select sum(r) from mytable;
> r
> -------
> 101.0

> I'd like to see the type of the 'r' column.

There's nothing built-in to psql, but you could modify the query, eg

select pg_typeof(sum(r)) from mytable;

(Adding "LIMIT 1" would be wise in most cases, though you don't need it
here.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Maciek Sakrejda 2010-09-22 23:11:17 Re: Nested literal parsing rules?
Previous Message Nils O. Selåsdal 2010-09-22 21:32:09 Re: Can psql show the column type of a result ?