You can assign aliases to the tables in the FROM clause
of a SELECT statement to make multiple-table queries shorter and more
readable. You can use an alias wherever the table name would be used,
for instance, as a prefix to the column names in the other clauses.
The associative nature of the SELECT statement allows
you to use an alias before you define it. In the query above, the
aliases s for the stock table, c for the catalog table,
and m for the manufact table are specified in the FROM
clause and used throughout the SELECT and WHERE clauses as column
prefixes.
Compare the length of Query with
the following query, which does not use aliases.
Query and Query are equivalent and retrieve
the data that the following query shows.
You cannot use the ORDER BY clause for the TEXT column cat_descr or
the BYTE column cat_picture.
You can use aliases to shorten
your queries on tables that are not in the current database.
The following query joins columns from two tables that
reside in different databases and systems, neither of which is the
current database or system.
By assigning the aliases c and o to the long database@system:table names, masterdb@central:customer and sales@western:orders,
respectively, you can use the aliases to shorten the expression in
the WHERE clause and retrieve the data, as the result shows.
For more information on how to access tables that are
not in the current database, see Access other database servers and the HCL OneDB™ Guide to SQL:
Syntax.
You
can also use synonyms as shorthand references to the long names of
tables that are not in the current database as well as current tables
and views. For details on how to create and use synonyms, see the HCL OneDB Database Design
and Implementation Guide.