select t.name from tbl t (where "name" is not a column name)

Поиск
Список
Период
Сортировка
От raf
Тема select t.name from tbl t (where "name" is not a column name)
Дата
Msg-id 20100224010750.GA18679@raf.org
обсуждение исходный текст
Ответы Re: select t.name from tbl t (where "name" is not a column name)  (Joe Conway <mail@joeconway.com>)
Список pgsql-general
hi,

i've just noticed the following behaviour and was wondering
if there's any documentation to explain what it's for.

  create table tbl(id serial primary key, a text, b text, c text);
  insert into tbl(a, b, c) values ('abc', 'def', 'ghi');
  insert into tbl(a, b, c) values ('jkl', 'mno', 'pqr');
  insert into tbl(a, b, c) values ('stu', 'vwx', 'yza');
  select t.name from tbl t;
  drop table tbl;

results in:

        name
  -----------------
   (1,abc,def,ghi)
   (2,jkl,mno,pqr)
   (3,stu,vwx,yza)

you can select t.name from tbl t even though "name" isn't the name
of a column in the table and you get this tuple-like version of the
each row. it doesn't work without the "t" alias and of course it
doesn't work if name really is the name of a column in the table.

so, what's this behaviour for, and, is there an equivalent
way to do it when "name" is the name of a column? i doubt
that i need this behaviour for anything. i'm just curious
and didn't see any mention of this in the documentation for
the select statement.

cheers,
raf


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

Предыдущее
От: Bryan Montgomery
Дата:
Сообщение: Trying to get a C function built with MSVC
Следующее
От: "Net Tree Inc."
Дата:
Сообщение: Re: [ADMIN] how do I do dump and restore without bugging with constraint?