You can assign an alias to the names of tables, columns, or column expressions in SQL statements and use the alias when referencing 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 aliasclause immediately after any table, column, or expression name in the
FROMlist of a query. The
ASkeyword is optional.
You can specify the alias immediately after the original name.
- You can specify column aliases with or without the
ASkeyword, and with no quotation marks, single quotation marks, or double quotation marks.
- Aliases are not case sensitive.
- Aliases can be up to the maximum length of a Java string, 2147483647.
- Aliases can include additional characters such as spaces and dashes
when they are quoted using backtick characters
- To use an alias name that matches one of the Impala reserved keywords, surround the identifier with either single or double quotation marks, or backtick characters.
- Aliases are allowed at the top level of the
ORDER BYclauses, e.g.
GROUP BY alias.
- Aliases are not allowed in subexpressions of the
ORDER BYclauses, e,g.
GROUP BY alias/5.