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

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

Question

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)?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top