Under a composite key unique constraint, does EACH value need to be unique (or just the combination)?

StackOverflow https://stackoverflow.com/questions/21233621

سؤال

I think this is a very basic question - so basic that I haven't been able to find an answer.

Let's say that two columns compose a composite key unique constraint: col_a and col_b.

Can two rows share a common value for col_a, as long as the combination of values for col_a and col_b are different? Or does each column need to be unique (like two separate UNIQUE constraints would require)?

هل كانت مفيدة؟

المحلول

If you have a unique composite key, then only the combination of column values has to be unique.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top