I have looked for threads that have discussed what the purpose of the "sequence" table is in a mysql environment but havent been able to find any which was really surprising. I'd think this issue would be a hot topic. I've had multiple problems when importing things as nodes into a drupal DB such as a bunch of text articles and every time I always have to update the sequence table with whatever ID auto_increment gives me. Since mysql keeps track of the ID's, isnt this a pretty redundant table and un-needed? I dont know about other DB types, maybe they dont do auto-increment tracking, but what DB wouldnt? To me this seems like a completely un-necessary step and should be completely ripped out or at least turned off if the DB engine being used is mysql.


jaydub’s picture

The sequence table is used _instead_ of using a MySQL auto_increment or PostgreSQL serial column.

Because of the differing methods of creating auto_increment/serial type columns in different databases, Drupal in the past has used plain INTEGER columns and used the sequence table to store an ID value to act as an auto_increment/serial type column.

Some contrib modules use the sequence method, which requires the use of db_next_id() function and some contrib modules use native MySQL or PostgreSQL sequence columns.

From what I understand Drupal 6 has moved in the direction of using native sequence columns so I think you will see the sequence table disappear in the future.

LanceLight’s picture

Thank god for that! I cant stand the use of the sequence table. It just made no sense to me at all :(. I truelly hope that someone sees the light and does away with it.

vegagitator’s picture

I have the Schema module installed on my multisite install of 6.9 and it lists the sequences table as an extra table. This doesn't always mean that the table is in fact extra. As Schema notes, not all modules use the Schema API, but core modules do. I've deleted all the sequences tables in my database (with a backup available of course) without any problems so far.