We are using in-memory tables in MySQL with an auto-incremented primary key.
After restarting MySQL the in-memory tables are emptied as expected.
However we would like to keep the auto increment value, so that the next inserted row will have the ID after the one that was used in the last session.
Is that possible?
We could not use the
ALTER TABLEstatement because a function was necessary to calculate the initial auto increment.The solution was to:
my.cnffile was changed, after the header[mysqld]we addedinit-file = [file_path]The file would execute a insert on the table with a dummy value (e.g.
INSERT INTO mytable(id) VALUES (UNIX_TIMESTAMP()). After this, the line can be deleted if wished.