3

刚发现Oracle不喜欢用AS关键字给子查询起别名:

SELECT * FROM (SELECT * FROM products) AS p

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

4

1 回答 1

4

SQL 99 ANSI 的模式是该表可以有一个没有关键字的别名因此AS,您可以取出AS它,它应该适用于每个 RDBMS。在小提琴上看到它:

ISO/IEC 9075-2:1999的第7.6 节 <table reference>中,第 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(喷气机)
于 2013-12-09T19:41:52.810 回答