MySQL Auto Increment Based on Foreign Key

前端 未结 2 527
旧巷少年郎
旧巷少年郎 2020-12-20 22:35

Lets say I have the following table called assets with the following fields:

id | job_id | title

I would like to use id and job_id as the p

相关标签:
2条回答
  • 2020-12-20 22:55

    If you mean specifically starting at zero, the documentation says auto_increment starts at 1 by design. However, "If the NO_AUTO_VALUE_ON_ZERO SQL mode is enabled, you can store 0 in AUTO_INCREMENT columns as 0 without generating a new sequence value."

    If you mean to recycle numbers that are no longer used in the table, that should happen automatically, if the removed numbers were the highest number used.

    0 讨论(0)
  • 2020-12-20 22:57

    If you use the MyISAM storage engine, the auto-increment column in a multi-column primary key starts over with each new value in the non-auto-increment column.

    See http://dev.mysql.com/doc/refman/5.1/en/example-auto-increment.html

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