MySQL UNIQUE Constraint with a condition -
i'm trying create unique index constraint 2 columns (id_1 , id_2) following condition: if 2 different rows have same value in id_2 column, values in id_1 column must same.
is possible?
thanks.
there no declarative constraint support such restriction. scenario describe not satisfy requirements unique constraint. (you can create constraint, won't able add more 1 row identical values id_1 , id_2.
if intent reject insert or update based on restriction, might able accomplish row-level trigger.
Comments
Post a Comment