disable validate
tp, July 19, 2004 - 3:32 am UTC
hi tom
could u tell me what is the use of disable validate constraint.can u give me a scenario where i can use this.
i am not able do any dml when the constraint is in disable validate state.
July 19, 2004 - 7:52 am UTC
metalink support note <Note:69637.1> has a good discussion of this.
The above metalink support not found
Arindam Mukherjee, August 21, 2006 - 2:35 am UTC
Respected Mr. Tom,
On altering constraint Disable Validate, table does now allow any DML statement irrespective of constrained column. In the Oracle 9i Data warehousing guide, chapter 7, the followings have been written.
************************************
However, there are trade-offs for the data warehouse administrator to consider with DISABLE VALIDATE constraints. Because this constraint is disabled, no DML statements that modify the unique column are permitted against the sales table. You can use one of two strategies for modifying this table in the presence of a constraint:
1. Use DDL to add data to this table (such as exchanging partitions). See the example in Chapter 14, "Maintaining the Data Warehouse".
2. Before modifying this table, drop the constraint. Then, make all necessary data modifications. Finally, re-create the disabled constraint. Re-creating the constraint is more efficient than re-creating an enabled constraint. However, this approach does not guarantee that data added to the sales table while the constraint has been dropped is unique.
************************************
Whats the practical usage of this constraint state if I drop and recreate as stated by point -2. If I dont use this opportunity (DISABLE VALIDATE), where and what type of problem I am likely to face.
August 27, 2006 - 9:04 am UTC
the practical usage is that while this constraint is in the disable validate mode - the table is for all intents and purposes "read only", "static", "known to be stable", "unmodifiable"
ops$tkyte%ORA10GR2> create table t ( x int, y int );
Table created.
ops$tkyte%ORA10GR2> insert into t values ( 1, 1 );
1 row created.
ops$tkyte%ORA10GR2> alter table t add constraint check_y check (y>0) disable validate;
Table altered.
ops$tkyte%ORA10GR2> update t set x = 2;
update t set x = 2
*
ERROR at line 1:
ORA-25128: No insert/update/delete on table with constraint
(OPS$TKYTE.CHECK_Y) disabled and validated
If that is something you desire, go for it.
Disable Validate - Documentation is misleading
Anindya, October 13, 2007 - 11:25 am UTC
Hi Tom,
In the point #2 quoted (from documentation) by Arindam above, says - "However, this approach does not guarantee that
data added to the sales table while the constraint has been dropped is unique."
Well, the "approach" mentioned here is -- Drop constrait -> DML -> create the constraint back as Disable Validate.
I found that it definitely guarantees the uniqueness, else the constraint creation fails. So the concern raised by by documentation does not look like a valid one.
The metalink note (Note:69637.1) is correct when it says -- "This option disallows all DML on the table, but
guarantees the validity of existing data"
October 14, 2007 - 2:28 pm UTC
validate will validate, yes - not sure what you mean?
we were not talking about using disable VALIDATE.
ops$tkyte%ORA10GR2> create table t ( x int constraint check_x unique );
Table created.
ops$tkyte%ORA10GR2> insert into t values ( 1 );
1 row created.
ops$tkyte%ORA10GR2> insert into t values ( 1 );
insert into t values ( 1 )
*
ERROR at line 1:
ORA-00001: unique constraint (OPS$TKYTE.CHECK_X) violated
ops$tkyte%ORA10GR2> alter table t drop constraint check_x;
Table altered.
ops$tkyte%ORA10GR2> insert into t values ( 1 );
1 row created.
ops$tkyte%ORA10GR2> alter table t add constraint check_x unique(x) disable;
Table altered.
ops$tkyte%ORA10GR2> select * from t;
X
----------
1
1