Drop an index

2024-04-19 08:42:50  Updated

The maintenance overhead increases with the number of indexes. You can drop unnecessary indexes based on your needs.

Use the ALTER TABLE statement to drop an index

The syntax is as follows:

obclient> ALTER TABLE table_name DROP KEY|INDEX index_name;

where

  • table_name specifies the name of the table from which the index is to be dropped.

  • KEY|INDEX indicates that you can use either the INDEX or the KEY keyword in the statement.

  • index_name specifies the name of the index to be dropped.

Example: Use the ALTER TABLE statement to drop an index.

obclient> ALTER TABLE t3 DROP KEY t3_uk, DROP KEY t3_ind3;
Query OK, 0 rows affected

Use the DROP INDEX statement to drop an index

The syntax is as follows:

obclient> DROP INDEX index_name ON table_name;

where

  • index_name specifies the name of the index to be dropped.

  • table_name specifies the name of the table from which the index is to be dropped.

Example: Use the DROP INDEX statement to drop an index.

obclient> DROP INDEX t3_ind3 ON t3;
Query OK, 0 rows affected

References

For more information about indexes supported by the MySQL mode of OceanBase Database, see the following topics:

Contact Us