---
title: 删除索引
description: "dropIndices API用于删除索引，可调用接口删除不再需要的索引表。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2300/bds/kunpengbds_omniruntime_20_0208.html
sourcePath: /source/zh/kunpengboostkithistory/2300/bds/kunpengbds_omniruntime_20_0208.html
indexId: aa016aa9017399b00e371b9db7e478fc0f6678f33e592c646102868eb122f52278
---
# 删除索引

dropIndices API用于删除索引，可调用接口删除不再需要的索引表。

#### dropIndices API

- dropIndices API

```
void dropIndices(TableName tableName, List<String> indexNames)
```


- 功能描述
  客户端删除索引请求接口，调用接口删除指定索引表。

- API描述

  1. 包名：package com.huawei.boostkit.hindex
  2. 类名：GlobalIndexAdmin
  3. 方法名：dropIndices
  4. 参数详情：| 参数名称 | 取值类型 | 描述 |
| --- | --- | --- |
| tableName | TableName | 用户数据表 |
| List<String> indexNames | List<String> | 将要删除的索引表 |


- 使用样例

```
//创建用户表myuser，并添加数据
Admin admin = connection.getAdmin();
TableName myuser = TableName.valueOf("myuser");
HTableDescriptor hTableDescriptor = new HTableDescriptor(myuser);
HColumnDescriptor f1 = new HColumnDescriptor("f1");
hTableDescriptor.addFamily(f1);
admin.createTable(hTableDescriptor);
try (Table table = conn.getTable(myuser)) {
Put put0 = new Put(Bytes.toBytes("001"));
put0.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("q1"), Bytes.toBytes("test"));
table.put(ImmutableList.of(put0));
}
//创建索引表myindex
TableIndices myindex = new TableIndices();
HIndexSpecification spec = new HIndexSpecification("myindex");
//对数据表f1列族的q1创建索引，数据类型是STRING
spec.addIndexColumn(Bytes.toBytes("f1"), Bytes.toBytes("q1"), ValueType.STRING);
myindex.addIndex(spec);
GlobalIndexAdmin globalIndexAdmin = GlobalIndexClient.newIndexAdmin(admin);
globalIndexAdmin.addIndicesWithData(myuser, myindex);
// 删除索引表myindex
globalIndexAdmin.dropIndices(myuser, Collections.singletonList("myindex"));
```


- 样例结果
  myindex索引表被成功删除。
