Tuesday, August 11, 2009

Oracle 9i:Constraints on views

Following design will not work:

Create table a (a number);

create view a_v as select * from a;

alter view a_v add constraint au unique(a) disable novalidate;

insert into a_v values(1);

insert into a_v values(1);

insert into a_v values(1);

commit;

All the values are entered in table and no constraints are validated.

Reason:

Constraints on views are not enforced but just stored in meta-data for more information. It is also used by optimizer to improve the performance.

Thanks,

Soham Khot