An index is a database structure created for a table to sort data in one or more columns of the table in a specific order. It mainly improves the query speed and reduces the performance overhead of database systems.
Create an index
Use the CREATE INDEX statement to create a table index.
Example:
Run the following command to create Table
test:obclient> CREATE TABLE test (c1 int primary key, c2 VARCHAR(10));Run the following command to create an index for Table
test:obclient> CREATE INDEX test_index ON test (c1, c2);For more information about the
CREATE INDEXstatement, see "CREATE INDEX".
View an index
Use the SHOW INDEX statement to view the index of a table.
Example:
View the index of Table test.
obclient> SHOW INDEX FROM test;
Delete an index
Use the DROP INDEX statement to delete the index of a table.
Example:
Delete the index of Table test.
obclient> DROP INDEX test_index ON test;
For more information about the DROP INDEX statement, see "DROP INDEX".