Two column as a primary keys in mysql?

前端 未结 8 1704
孤独总比滥情好
孤独总比滥情好 2020-12-15 06:34

Today I found out you can have a primary key using two columns (tsql). The PK must be unique but both columns do not (the combo must be unique).

I thought that was v

相关标签:
8条回答
  • 2020-12-15 07:01

    Yes you have to be aware of duplicating your PRIMARY_KEY which is a combined key in your case not to be duplicated.

    Anyway when you set two PK's this means that your signature is PK1+PK2 so you can duplicate PK1 or PK2 but not the both of them.

    Hope that I helped

    0 讨论(0)
  • 2020-12-15 07:03

    You are over thinking this:

    • primary keys (no matter how many columns are involved) must be unique
    • your primary key is the two columns a, b

    Therefore a and b together must be unique.

    Individual value of a and b are irrelevant.

    0 讨论(0)
提交回复
热议问题