Is there a syntax for renaming an index in MariaDB? I understand that MySQL 5.7 supports the syntax, but does MariaDB 10.0 (which includes MySQL 5.6) support it?
They added the option on version 10.5.2, but I'm not sure it works because I have the vs 10.3 in my servers. https://mariadb.com/kb/en/alter-table/#rename-indexkey
I'll update it with more info.
I just tried ALTER TABLE thing RENAME INDEX ix_old TO ix_new;
in MariaDB 10.2.12 and it failed.
It also doesn't appear in the docs at https://mariadb.com/kb/en/library/alter-table/
And mysteriously an answer to this question displayed in duckduckgo doesn't exist! It said
No, there is no way to rename an index in current versions of MySQL (up to 5.6) or MariaDB (up to 10) or Percona Server (up to 5.6).
You can only drop an index and create a new index of a different name.
As a workaround, you could use pt-online-schema-change to add a new index with the new name and drop the old index by its old name, while allowing continuous read/write access to the original table.
$ pt-online-schema-change --alter "ADD KEY new_idx_name, DROP KEY old_idx_name" \ D=mydatabase,t=mytable
--Bill Karwin
But Bill Karwin's edit to the question remains. Hmmm, why would he have deleted it?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With