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?
Mysql auto increment primary key id’s
auto-incrementMySQLprimary-key
Related Topic
- Mysql – How to find all tables that have foreign keys that reference particular table.column and have values for those foreign keys
- Mysql – Remove Primary Key in MySQL
- Mysql – How to properly create composite primary keys – MYSQL
- MySQL > Table doesn’t exist. But it does (or it should)
- Mysql – How to reset AUTO_INCREMENT in MySQL
- Sql-server – What are the best practices for using a GUID as a primary key, specifically regarding performance
- MySQL Error 1215: Cannot add foreign key constraint
- Mysql – How to import an SQL file using the command line in MySQL
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!).