一尘不染

Oracle AS关键字和子查询

sql

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

SELECT * FROM (SELECT * FROM products) AS p

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


阅读 174

收藏
2021-03-10

共1个答案

一尘不染

对于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(喷射)
2021-03-10