9

According to PostgreSQL 7.1 through 9.1 (now unsupported), ALIAS is listed as a reserved word, at least for SQL-99. Later versions do not show it - suggesting that it has been dropped as a reserved word. The old PostgreSQL docs do say "the presence of a key word does not indicate the existence of a feature." When aliasing a table or column I've seen AS, but never ALIAS.

Where is (or was) the SQL keyword ALIAS used? Was it ever in-use or only ever reserved for future-use?

16

PostgreSQL maintains a list of reserved and non-reserved terms in the appendix. ALIAS is absent from that list. You can verify PostgreSQL does not use ALIAS by checking out the YACC grammar. Even as far back as Postgres95 ALIAS was not a reserved word (the first version in the migration from QUEL to SQL)

SQL Standard

  • In SQL-92, ALIAS was marked as a <reserved word>; but, there was no use assigned for that <reserved word>.

  • In SQL-99 ALIAS was marked as an "Additional Reserved Word", and added to the list of <reserved word>; but, there was no use assigned for that <reserved word>. Perhaps they reserved the term with the intent to define meaning later, and then withdrew it at a different point. Or, perhaps they reserved the term for vendor defined implementation. PostgreSQL reflected the spec's reservation in the docs, and then removed that reservation with the spec.

  • In SQL-2011, ALIAS is no where to be found and the word "alias" only appears in reference to 'Feature T053, “Explicit aliases for all-fields reference”'

ℹ There is no digitized copy of SQL-86, or SQL-89

8

It is used at least in various flavours of Db2: ALIAS is an object that allows you to specify a different name for another object, like table. It's frequently used to allow references in one schema to objects in another schema without explicitly specifying that schema.

create table SOMEOTHERSCHEMA.FOOBAR (...);
set schema MYSCHEMA;
create alias FOOBAR for SOMEOTHERSCHEMA.FOOBAR;
select * from FOOBAR;

ALIAS is an alias for SYNONYM; the latter concept also exists in Oracle and SQL Server.

3

Actually, there is a place where the keyword ALIAS is used in all versions of PostgreSQL.

Not in SQL, though, like Evan clearly documented. But in the procedural language PL/pgSQL to create aliases for parameters or variables.

It was more commonly used before Postgres 8.0 while named parameters were not yet supported for PL/pgSQL functions. Since then, only few use cases are left. The manual concludes:

It's best to use it only for the purpose of overriding predetermined names.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.