Re: Can psql show the column type of a result ? - Mailing list pgsql-general

From Tom Lane
Subject Re: Can psql show the column type of a result ?
Date
Msg-id 2587.1285192285@sss.pgh.pa.us
Whole thread Raw
In response to Can psql show the column type of a result ?  ("Nils O. Selåsdal" <noselasd@asgaard.homelinux.org>)
List pgsql-general
=?UTF-8?B?Ik5pbHMgTy4gU2Vsw6VzZGFsIg==?= <noselasd@asgaard.homelinux.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

pgsql-general by date:

Previous
From: Richard Broersma
Date:
Subject: Re: Can psql show the column type of a result ?
Next
From: Maciek Sakrejda
Date:
Subject: Re: Nested literal parsing rules?