I would like to know what behavior / differences between a Unique Index and Unique Constraints for Informix ?
I would like to know what behavior / differences between a Unique Index and Unique Constraints for Informix ?
Many should think that this does not make a difference in the database, but it does! And not only for the DBA / Administrator, but for developers too as it can influence how a code is written.
I work a lot with IBM Informix and know that there are differences below.
UPDATE tp01 SET cod = cod + 1;
on a table that the cod field is sequential and with unique index, this update would give error on the 1st line since it would already duplicate (or even primary key constraint)
UPDATE tp01 SET cod = cod + 1;
, it would work without problems because it will validate the uniqueness only when finalizing the update of all the lines involved. commit
. This is possible when the set constraints [all|<constraint>] deffered;
command is used before the updates.
So in the above update example, it will only validate the uniqueness when commit is sent to the database. Note: This feature is valid for all types of constraints (PK, FK, UK)