What is this doing? SELECT (a,b,c) FROM mytable ...

From: ljb <ljb9832(at)pobox(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: What is this doing? SELECT (a,b,c) FROM mytable ...
Date: 2011-04-23 01:46:19
Message-ID: iotb1b$g6u$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

What syntax or operator did I (accidentally) invoke by putting parentheses
around my column list?
SELECT (a, b, c) FROM mytable...
It gets me a single result column with comma-separated values in
parentheses (see 2nd SELECT below). I can't find an explanation in the
PostgreSQL manual. It doesn't seem to be an array, a subquery, row
constructor, etc. What sort of thing is it?

test=> CREATE TABLE mytable (a INTEGER, b INTEGER, c INTEGER);
test=> INSERT INTO mytable VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9);
test=> SELECT a, b, c FROM mytable ORDER BY 1;
a | b | c
---+---+---
1 | 2 | 3
4 | 5 | 6
7 | 8 | 9
(3 rows)

test=> SELECT (a, b, c) FROM mytable ORDER BY 1;
row
---------
(1,2,3)
(4,5,6)
(7,8,9)
(3 rows)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-04-23 03:05:08 Re: What is this doing? SELECT (a,b,c) FROM mytable ...
Previous Message Jorge Arévalo 2011-04-23 01:19:21 Should I free this memory?