views:

39

answers:

1

Is there a way to easily get the column types of a query result? I read the psql documentation, but I don't think it supports that. Ideally, I'd be able to get something like:

 columna : text | columnb : integer
----------------+-------------------
 oh hai         |                42

Is there a way I can get this information without coding something up?

+1  A: 

I don't think you can print exactly what you have in the sample, unless you write a stored procedure for it.

One way to do it (two "selects"):

  1. create table my_table as select ...
  2. \d my_table
  3. select * from my_table
Konrad Garus
Yeah, I just needed the types, not necessarily that format. Thanks.
Justin K