刚刚发现,Oracle不喜欢使用AS
关键字给子查询取别名:
SELECT * FROM (SELECT * FROM products) AS p
我需要尽可能保持我的SQL查询具有可移植性。上述查询中删除AS
关键字是否会影响其他关系型数据库管理系统(RDBMS)?
刚刚发现,Oracle不喜欢使用AS
关键字给子查询取别名:
SELECT * FROM (SELECT * FROM products) AS p
我需要尽可能保持我的SQL查询具有可移植性。上述查询中删除AS
关键字是否会影响其他关系型数据库管理系统(RDBMS)?
SQL 99 ANSI的模式是表可以有一个别名WITHOUTAS
关键字,因此,您可以省略AS
并在每个RDBMS上运行。请参见fiddle:
在ISO/IEC 9075-2:1999,第232页,第7.6节“<table reference>”中:
<table reference> ::=
<table primary>
| <joined table>
<table primary> ::=
<table or query name> [ [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ] ]
| <derived table> [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ]
| <lateral derived table> [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ]
| <collection derived table> [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ]
| <only spec>
[ [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ] ]
| <left paren> <joined table> <right paren>
还确认可以使用:
AS
关键字的用法。 - Max Toro