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

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

Pergunta

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

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top