Aliases
When you write the names of tables, columns, or column expressions in a query, you can assign an alias at the same time. Then you can specify the alias rather than the original name when making other references to the table or column in the same statement. You typically specify aliases that are shorter, easier to remember, or both than the original names. The aliases are printed in the query header, making them useful for self-documenting output.
To set up an alias, add the AS alias clause immediately after any table, column, or expression name in the SELECT list or FROM list of a query. The AS keyword is optional; you can also specify the alias immediately after the original name.
To use an alias name that matches one of the Impala reserved keywords (listed in Appendix C - Impala Reserved Words), surround the identifier with either single or double quotation marks, or `` characters (backticks).
select c1 as name, c2 as address, c3 as phone from table_with_terse_columns; select sum(ss_xyz_dollars_net) as total_sales from table_with_cryptic_columns; select one.name, two.address, three.phone from census one, building_directory two, phonebook three where one.id = two.id and two.id = three.id;
Aliases follow the same rules as identifiers when it comes to case insensitivity. Aliases can be longer than identifiers (up to the maximum length of a Java string) and can include additional characters such as spaces and dashes when they are quoted using backtick characters.
Alternatives:
Another way to define different names for the same tables or columns is to create views. See Views for details.
<< Schema Objects and Object Names | Databases >> | |