How do I combine check constraint with unique constraint

  • Does anyone know how or if I can combine a check constraint with unique constraint? For example tbla has 3 columns, col1, col2, col3. col1 and col2 must be unique if col3 is a certain value.

  • This was removed by the editor as SPAM

  • Sounds to me like you might need to control that particular scenario programmatically.

    From my understanding, you usually define uniqueness via an index but I don't believe they are conditional.

    As for looking at it from the other end, i.e. creating a check constraint, I don't think you can access the whole table to see if a certain value exists - unless you can use a user defined function to confirm the existence of the the required value. Can't say I've tried it but it might be worth a look.


    Regards,

    Steve

    Life without beer is no life at all

    All beer is good, some beers are just better than others

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply