当您使用AS
关键字为子查询设置别名时,发现Oracle不喜欢它:
SELECT * FROM (SELECT * FROM products) AS p
我需要尽可能地保持SQL查询的可移植性。上述查询中AS
关键字的删除是否会影响任何其他RDBMS?
答案 0 :(得分:4)
SQL 99 ANSI的模式是该表可以使用别名 WITHOUT AS
关键字,因此,您可以取出AS
并且它应该适用于每个RDBMS。在小提琴上看到它:
在ISO/IEC 9075-2:1999, 7.6<表格参考> ,第232页
部分<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>
也确认工作: