简体   繁体   中英

Should I select auto-increment and primary key for the same SQL table column

I am creating a MySQL table with a primary key column; should I also select the auto-increment option or does primary key already do that?

Definitely You should select both. and the reason why you select both is below

  1. Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table.

    Often this is the primary key field that we would like to be created automatically every time a new record is inserted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM