Deferred Constraints
A deferred constraint is enforced when a transaction is committed.
Uou use the DEFERRABLE
clause when you initially add the constraint.
Once you've added a constraint,you cannot change it to DEFERRABLE
.
You have to drop and re-create the constraint.
A DEFERRABLE
constraint can be marked as INITIALLY IMMEDIATE
or INITIALLY DEFERRED
.
INITIALLY IMMEDIATE
constraint is checked whenever you add, update, or delete rows from a table.
INITIALLY DEFERRED
constraint is checked when a transaction is committed.
SQL> CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
2 ENAME VARCHAR2(10),
3 JOB VARCHAR2(9),
4 SAL NUMBER(7, 2),
5 DEPTNO NUMBER(2));
Table created.
SQL>
SQL> ALTER TABLE emp
2 ADD CONSTRAINT my_uq UNIQUE (ename)
3 DEFERRABLE INITIALLY DEFERRED;
Table altered.
SQL>
Home »
Oracle »
Table »
Oracle »
Table »
Constraints:
- Adding a Constraint with CHECK
- Adding a NOT NULL Constraint
- Adding a FOREIGN KEY Constraint
- ON DELETE CASCADE
- ON DELETE SET NULL
- Adding a UNIQUE Constraint
- CHECK constraint
- Multiple Constraints
- Dropping a Constraint
- Disabling a Constraint
- Enabling a Constraint
- Deferred Constraints
- Getting Information on Constraints:user_constraints and all_constraints
Related: