Home > database >  On the issue of the oracle's uniqueness constraints, urgent ~!!!!!! Online ~ ~!!!!!!
On the issue of the oracle's uniqueness constraints, urgent ~!!!!!! Online ~ ~!!!!!!

Time:09-28

Now there is a demand, increase uniqueness constraints for part of the data, delete data for logic, but want to add uniqueness constraints on not deleted data

Similar to the
Add constraint alter table XXX XXX unique (field 1, 2, and field 3) where is_del=0
This logic could you tell me how to write SQL should be urgent ~ ~ ~!!!!!! Thank you ~ ~!!!!!!

CodePudding user response:

I have added a unique index
Create unique index uq_name_idx on XXX (nvl2 (nullif (is_del, 1), field 1, null, nvl2 (nullif (is_del, 1), field 2, null, nvl2 (nullif (is_del, 1), field 3, null));

CodePudding user response:

CodePudding user response:

The original poster is mysql or oracle?
  • Related