Oracle AS keyword and subqueries

后端 未结 1 737
星月不相逢
星月不相逢 2020-12-19 21:02

Just found out that Oracle does not like it when you use the AS keyword to alias a subquery:

SELECT * FROM (SELECT * FROM products) AS p
         


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-19 21:52

    The pattern for the SQL 99 ANSI is that the table can have an alias WITHOUT the AS keyword so, you can take out AS and it should work on every RDBMS. See it on fiddle:

    • MySQL
    • Oracle
    • PostgreSql
    • SQLLite
    • SQLServer

    In ISO/IEC 9075-2:1999, section 7.6

    , page 232:

    ::=
    |
    ::=
    [ [ AS ] [ ] ] | [ AS ] [ ] | [ AS ] [ ] | [ AS ] [ ] | [ [ AS ] [ ] ] |

    Also confirmed to work:

    • MS Access (Jet)

    0 讨论(0)
    提交回复
    热议问题