- Statement execution, for nondeferred constraints
- COMMIT, for deferred constraints
So the order is (case: DML statement, followed by COMMIT):
- Nondeferred constraints checked
- COMMIT issued
- Deferred constraints checked
- COMMIT complete
Non-deferred constraints are enforced at the end of every DML statement and a violation causes the statement to roll back.
Deferred constraints are enforced when a transaction is committed and a violation causes the transaction to roll back.
A constraint that is defined as deferrable can be specified as one of the following:
- Initially immediable: specifies that by default it must function as an immediate constraint unless explicitly set otherwise using SET CONSTRAINT {constraint name, ... ALL} {IMMEDIATE DEFERRED}
- Initially deferred: specifies that by default the constraint must be enforced only at the end of the transaction.

No comments:
Post a Comment