Auto_increment values in InnoDB?

前端 未结 5 584
眼角桃花
眼角桃花 2020-12-18 01:00

I\'ve been using InnoDB for a project, and relying on auto_increment. This is not a problem for most of the tables, but for tables with deletion, this might be an issue:

5条回答
  •  生来不讨喜
    2020-12-18 01:12

    So you have two tables:

    TableA

    A_ID [PK]

    and

    TableB

    B_ID [PK]

    A_ID [FK, TableA.A_ID]

    And in TableB, the value of A_ID is not unique? Or is there a value in TableB.A_ID that is not in TableA.A_ID?

    If you need the value of TableB.A_ID to be unique, then you need to add a UNIQUE constraint to that column.

    Or am I still missing something?

提交回复
热议问题