Oracle AS关键字和子查询

时间:2013-12-09 19:36:56

标签: sql oracle rdbms rdbms-agnostic

当您使用AS关键字为子查询设置别名时,发现Oracle不喜欢它:

SELECT * FROM (SELECT * FROM products) AS p

我需要尽可能地保持SQL查询的可移植性。上述查询中AS关键字的删除是否会影响任何其他RDBMS?

1 个答案:

答案 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>

也确认工作:

  • MS Access(Jet)