For an integrity constraint to appear in a DISABLE clause, one of the following conditions must be true:
UNIQUE Keywords and Parameters
disables the UNIQUE constraint defined on the specified column or combination of columns.
CONSTRAINT
disables the integrity constraint with the name constraint.
CASCADE
ALL TRIGGERS
You can also disable an integrity constraint with the DISABLE keyword in the CONSTRAINT clause that defines the integrity constraint. For information on this keyword, see the CONSTRAINT clause .
How Oracle7 Disables Integrity Constraints If you disable an integrity constraint, Oracle7 does not enforce it. If you define an integrity constraint and disable it, Oracle7 does not apply it to existing rows of the table, although Oracle7 does store it in the data dictionary along with enabled integrity constraints. Also, Oracle7 can execute Data Manipulation Language statements that change table data and violate a disabled integrity constraint.
If you disable a UNIQUE or PRIMARY KEY constraint that was previously enabled, Oracle7 drops the index that enforces the constraint.
You can enable a disabled integrity constraint with the ENABLE clause.
Disabling Referenced Keys in Referential Integrity Constraints To disable a UNIQUE or PRIMARY KEY constraint that identifies the referenced key of a referential integrity constraint, you must also disable the foreign key. To disable a constraint and all its dependent constraints, use the CASCADE option of the DISABLE clause.
You cannot enable a foreign key that references a unique or primary key that is disabled.
Example I
The following statement creates the DEPT table and defines a disabled PRIMARY KEY constraint:
CREATE TABLE dept
(deptno NUMBER(2) PRIMARY KEY,
dname VARCHAR2(10),
loc VARCHAR2(9) )
DISABLE PRIMARY KEY
Since the primary key is disabled, you can add rows to the table that violate the primary key. You can add departments with null department numbers or multiple departments with the same department number.
Example II
The following statement defines and disables a CHECK constraint on the EMP table:
ALTER TABLE emp
ADD (CONSTRAINT check_comp CHECK (sal + comm <= 5000) )
DISABLE CONSTRAINT check_comp
The constraint CHECK_COMP ensures that no employee's total compensation exceeds $5000. Since the constraint is disabled, you can increase an employee's compensation above this limit.
Example III
Consider a referential integrity constraint involving a foreign key on the combination of the AREACO and PHONENO columns of the PHONE_CALLS table. The foreign key references a unique key on the combination of the AREACO and PHONENO columns of the CUSTOMERS table. The following statement disables the unique key on the combination of the AREACO and PHONENO columns of the CUSTOMERS table:
ALTER TABLE customers DISABLE UNIQUE (areaco, phoneno) CASCADE
Since the unique key in the CUSTOMERS table is referenced by the foreign key in the PHONE_CALLS table, you must use the CASCADE option to disable the unique key. This option disables the foreign key as well.
Example IV
The following statement disables all triggers associated with the EMP table:
ALTER TABLE emp
DISABLE ALL TRIGGERS