Re: [NOVICE] what does t(x) in select x from generate_series(1, 10)as t(x) stand for?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [NOVICE] what does t(x) in select x from generate_series(1, 10)as t(x) stand for?
Дата
Msg-id CAKFQuwb2sYzkP8YDuw=7QyQYm5165XtPAR8Wpm_mDKJpmcH14g@mail.gmail.com
обсуждение исходный текст
Ответ на [NOVICE] what does t(x) in select x from generate_series(1, 10) as t(x) stand for?  (john snow <ofbizfanster@gmail.com>)
Ответы Re: [NOVICE] what does t(x) in select x from generate_series(1, 10) as t(x) stand for?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
On Wednesday, November 8, 2017, john snow <ofbizfanster@gmail.com> wrote:
is 
select x from generate_series(1, 10) as t(x);
different from
select x from generate_series(1, 10) as x;

both statements seem to produce the same result in pgAdmin4 (i'm using postresql version 10)


Not sure about the pgAdmin part but t(x) means that you are aliasing the table result of the generate_series call to the name "t" and that tables' first (and in this case only) column is aliased to the name "x".   The x in the select is then that first column.  In the "as x" variant all you've done is alias the table to the name "x" and the "x" in the select refers to the table.  Not able to confirm right now but the first result should yield a column of type bigint while the second should a composite whose only column is a bigint and whose name is "generate_series".  There may be something special for "SETOF type" results but if your function is "returns table(...)" the distinction definitely matters.

David J.

В списке pgsql-novice по дате отправления:

Предыдущее
От: john snow
Дата:
Сообщение: [NOVICE] what does t(x) in select x from generate_series(1, 10) as t(x) stand for?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [NOVICE] what does t(x) in select x from generate_series(1, 10) as t(x) stand for?