Peter Eisentraut's PostgreSQL Activities

SELECT without AS

Here is a patch that allows you to specify column aliases in the select list without having to write AS. For example, you could write this:

SELECT a b FROM test;

This is particularly handy when porting from some proprietary database systems that don't allow you to write AS there, as PostgreSQL normally requires.

Adding the functionality requires making several key words more reserved. These are:

AT
BIT
CHAR
CHARACTER
DAY
HOUR
MINUTE
MONTH
NCHAR
OPERATOR
PRECISION
SECOND
WITH
WITHOUT
YEAR

With the exception of OPERATOR, all these are supposed to be reserved words according to the SQL standard, so portable applications should avoid their use anyway.

There are also other ways to do this. For example, one could reserve DOUBLE instead of PRECISION, but it has to be one of these two. One could also try to reshuffle the key word categories even more to arrive at more optimal results. This is just one possibility to give you an idea.

The patch is meant for PostgreSQL 7.4, but could easily be adjusted to other versions. To install the patch, execute the following the in the top-level of the PostgreSQL source tree:

patch -p0 < ..../select-without-as.patch

After that, rebuild and reinstall. Rerunning initdb is not necessary.

Peter Eisentraut -- peter_e@gmx.net -- petere@postgresql.org