Обсуждение: Problem about pgsql's column alias

Поиск
Список
Период
Сортировка

Problem about pgsql's column alias

От
"milimeter@163.com"
Дата:
Hello, everybody

  I found that in postgresql, we can only use "select login_name as name from
users;" to get an alias "name" for column "login_name", but in most other
databases we can omit the "as", that is "select login_name name from users;".

  Now I will convert a lot of program from oracle to postgresql, there're so
many place to be correct from "AAA BBB" to "AAA as BBB", can anybody give me
a good method to do that? Or, if the next version of postgresql will have the
same feature as other databases?

  Thanks a lot,
  Yours,
  mili


Re: Problem about pgsql's column alias

От
Tom Lane
Дата:
"milimeter@163.com" <milimeter@163.com> writes:
>   I found that in postgresql, we can only use "select login_name as name from
> users;" to get an alias "name" for column "login_name", but in most other
> databases we can omit the "as", that is "select login_name name from users;".

AS is not optional in Postgres, and will never be so unless we choose to
drop support for postfix operators, which I consider an unlikely choice.
Example: in
        SELECT foo ! bar;
is the "!" an infix operator, or is it postfix with the intended meaning
        SELECT (foo!) AS bar;

            regards, tom lane