How to make `CREATE INDEX` using the Percona tool` pt-online-schema-change`?

How to make CREATE INDEX using the Percona tool pt-online-schema-change ? I want to do something like:

CREATE UNIQUE INDEX idx_name ON table_name (col_1, col_2, ...) USING BTREE

According to the documentation , I should use the --alter argument, and then the corresponding ALTER TABLE , minus the previous phrase ALTER TABLE table_name . However, CREATE INDEX does not start with ALTER TABLE , and the table name is embedded in the CREATE INDEX statement. So how can I move forward?

+6
source share
1 answer

According to the documentation for MySQL CREATE INDEX :

CREATE INDEX maps to an ALTER TABLE statement to create indexes.

This way you can convert your example into an SQL statement:

ALTER TABLE table_name ADD UNIQUE INDEX idx_name (col_1, col_2, ...) USING BTREE

The result in the Percona schema modification instruction:

ADD UNIQUE INDEX idx_name (col_1, col_2, ...) USING BTREE

+6
source

Source: https://habr.com/ru/post/976166/


All Articles