Is the 'as' keyword required in Oracle to define an alias?
(Tested on Oracle 11g
)
About AS
:
- When used on result column,
AS
is optional. - When used on table name,
AS
shouldn't be added, otherwise it's an error.
About double quote
:
- It's optional & valid for both result column & table name.
e.g
-- 'AS' is optional for result column
select (1+1) as result from dual;
select (1+1) result from dual;
-- 'AS' shouldn't be used for table name
select 'hi' from dual d;
-- Adding double quotes for alias name is optional, but valid for both result column & table name,
select (1+1) as "result" from dual;
select (1+1) "result" from dual;
select 'hi' from dual "d";
According to the select_list Oracle select documentation the AS is optional.
As a personal note I think it is easier to read with the AS