[TOC] # 索引操作 索引是创建在表上并对数据库表中一列或多列的值进行排序的一种结构。其作用主要在于提高查询的速度,降低数据库系统的性能开销。 ## 创建索引 使用`CREATE INDEX`语句创建表的索引。 示例: 1. 执行以下命令,创建表`test`。 ~~~ obclient> CREATE TABLE test (c1 int primary key, c2 VARCHAR(10)); ~~~ 2. 执行以下命令,创建表 test 的索引。 ~~~ obclient> CREATE INDEX test_index ON test (c1, c2); ~~~ 更多`CREATE INDEX`语句相关的语法说明请参见《SQL 参考(MySQL 模式)》中的[CREATE INDEX](https://open.oceanbase.com/docs/community/oceanbase-database/V3.1.0/create-index)[CREATE INDEX](https://open.oceanbase.com/docs/community/oceanbase-database/V3.1.0/create-index)章节。 ## 查看索引 使用`SHOW INDEX`语句查看表的索引。 示例如下: 查看表`test`的索引。 ~~~ obclient> SHOW INDEX FROM test; ~~~ ## 删除索引 使用`DROP INDEX`语句删除表的索引。 示例如下: 删除表`test`的索引。 ~~~ obclient> DROP INDEX test_index ON test; ~~~ 更多`DROP INDEX`语句相关的语法说明请参见《SQL 参考(MySQL 模式)》中的[DROP INDEX](https://open.oceanbase.com/docs/community/oceanbase-database/V3.1.0/drop-index)章节。