Mysql auto increment primary key id’s

auto-incrementMySQLprimary-key

I have some mysql tables that have auto incrementing id's that are primary keys, but I notice that I never actually use them… I used to think that every table must have a primary key so I guess that is why I created them before. Should I remove them all if I don't use them at all?

Best Answer

Unless you are running into space problems I wouldn't remove them.

They are a life saver in case you by mistake (or oversight) populate the database with repeated/wrong data.

They also help to have related tables, where you reference the content on one table through the autogenerated id.

This is assuming you have indexes for the other columns you use to actually query the data (if you don't, then more reason to keep the autoincrement ids and use them!).