NOT DEFERRABLE versus DEFERRABLE INITIALLY IMMEDIATE

前端 未结 5 1401
有刺的猬
有刺的猬 2020-12-02 06:51

I read this about the SQL keyword DEFERRABLE in Database Systems - The Complete Book.

The latter [NOT DEFERRABLE] is defau

5条回答
  •  伪装坚强ぢ
    2020-12-02 07:05

    I'm very late to the party but I wanted to add that -- as of December 2018 -- only two databases I know of (there may be more) offer some level of implementation of this standard SQL feature:

    Database    NOT DEFERRABLE  DEFERRABLE           DEFERRABLE 
                                INITIALLY IMMEDIATE  INITIALLY DEFERRED
    ----------  --------------  -------------------  ------------------
    Oracle      N/A *1          Yes (default)        Yes
    PostgreSQL  Yes (default)   Yes                  Yes
    DB2         -               -                    -
    SQL Server  -               -                    -
    MySQL       -               -                    -
    MariaDB     -               -                    -
    SAP Sybase  -               -                    -
    HyperSQL    -               -                    -
    H2          -               -                    -
    Derby       -               -                    -
    

    *1 Even though Oracle 12c accepts the NOT DEFERRABLE constraint state, it actually ignores it and makes it work as DEFERRABLE INITIALLY IMMEDIATE.

    As you see, Oracle does not implement the first type (NOT DEFERRABLE), and that's why developers using Oracle (the OP in this case) may get confused and consider the first two types equivalent.

    Interestingly enough Oracle and PostgreSQL have a different default type. Maybe it has performance implications.

提交回复
热议问题