Search code examples
mysqlindexingb-tree

How to change a HEAP/MEMORY MySQL table's indexes from HASH to BTREE?


I have a MySQL table with the HEAP/MEMORY storage type that was converted from MyISAM. The indexes were automatically converted to HASH, but I need them to be BTREE. How do I change them from HASH to BTREE?


Solution

  • Dropping the indexes does work, but this wouldn't work with the PRIMARY KEY without doing this:

    ALTER TABLE table DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE (id);