to auto increment or not to
Moderator: General Moderators
to auto increment or not to
For the ID column of a table, is there any reason not to auto increment? I know for replication it could be a problem, having to disable it on the replicated servers... but other than that is there any other problem with auto incrementing ids?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
It's largely dependant on how your system needs to work. Generally speaking, I use auto_increment on the primary ID column nearly always. Whether a table has such a column or not depends on the function of the table. Cross linking tables rarely, if ever, need such a column for instance. Ancillary user tables will often have the user_id as primary key, since it's foreign, it's not auto-incremented.