Examples in this section show workarounds that use the AS keyword with a table alias. The first pair shows how to use the ORDER, FOR, GROUP, HAVING, INTO, UNION, WITH, CREATE, GRANT, or WHERE keyword as a table alias.
Using order as a table alias causes the following example to fail because the database server interprets order as part of an ORDER BY clause:
SELECT * FROM mytab order -- fails
The workaround in the following example uses the keyword AS to identify order as a table alias:
SELECT * FROM mytab AS order;
The next two examples show how to use the keyword WITH as a table alias.
Using with as a table alias causes the next example to fail because the database server interprets with as part of the WITH CHECK OPTION syntax:
EXEC SQL select * from mytab with; -- fails
The workaround in the following example uses the keyword AS to identify with as a table alias:
EXEC SQL select * from mytab as with; -- succeeds
The next two examples use the keyword CREATE as a table alias. Using create as a table alias causes the next example to fail because the database server interprets the keyword as part of the syntax to create a new database object, such as a table, synonym, or view:
EXEC SQL select * from mytab create; -- fails
EXEC SQL select * from mytab as create; -- succeeds
The workaround uses the keyword AS to identify create as a table alias.
(Using grant as an alias would similarly fail, but is valid after
the AS keyword.)