How does MySQL Auto Increment work?

后端 未结 5 919
星月不相逢
星月不相逢 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:05

    Yes, that's the exact purpose of AUTO_INCREMENT. It looks at whatever is the current increment value for that table, and stores that value plus 1 for the new row that comes in, automatically. You can omit that field from your INSERT statements and MySQL will handle it for you for every new row that comes in, giving each row its own unique ID.

提交回复
热议问题