How does MySQL Auto Increment work?

后端 未结 5 918
星月不相逢
星月不相逢 2020-12-01 21:15

I was just creating a new table using MySQL Query Browser, and noticed there\'s a tick under Auto Increment Column. How does that work?

When adding to the database p

5条回答
  •  一个人的身影
    2020-12-01 22:16

    Yes. Auto_Increment columns work like they say on the tin. Tips

    • when INSERT - ing, use NULL or omit the column

    • Use LAST_INSERT_ID() (or API equivalents) to obtain the last generated value.

    • for security and business logic reasons, it's usually better form to not directly use a key value for a customer identifier. Consider using Hashed / randomised surrogate customer keys instead.

    Ta

提交回复
热议问题