What exactly does SQLite's “NO ACTION” foreign key constraint do and how is it different from “RESTRICT”?

后端 未结 1 1318
攒了一身酷
攒了一身酷 2021-01-18 08:14

The documentation says:

Configuring \"NO ACTION\" means just that: when a parent key is modified or deleted from the database, no special action is

1条回答
  •  盖世英雄少女心
    2021-01-18 08:43

    The introducing paragraph says:

    If an action is not explicitly specified, it defaults to "NO ACTION".

    This is the normal action.

    Furthermore:

    The difference between the effect of a RESTRICT action and normal foreign key constraint enforcement is that the RESTRICT action processing happens as soon as the field is updated - not at the end of the current statement as it would with an immediate constraint, or at the end of the current transaction as it would with a deferred constraint.

    If you're testing with a single-statement transaction that changes just one record, you will not see any difference between NO ACTION and RESTRICT.

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