I always see MySQL database primary keys as integers. Is that because primary keys must be integers, or because of ease of use when setting auto_increment on the column?
I am wondering just in case I want my primary key to be a varchar in the future.
You can use
varcharas well as long as you make sure that each one is unique. This however isn’t ideal (see article link below for more info).What you are looking for is called natural key but a primary key with auto-increment and handled by the RDBMS is called surrogate key which is preferred way. Therefore you need to have it to be integer.
Learn more: