> For the complete documentation index, see [llms.txt](https://litedb.gitbook.io/litedb-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://litedb.gitbook.io/litedb-docs/sql/ddl/scalar_index/drop_index.md).

# DROP INDEX

`DROP INDEX` 用于删除当前数据库中指定集合上的标量索引。

## 语法

```ebnf
drop_index_statement ::= DROP INDEX [ IF EXISTS ] index_name ON collection_name

index_name ::= identifier
collection_name ::= identifier
```

索引名称写在 `IF EXISTS` 后，集合名称写在 `ON` 后。删除向量索引应使用 [DROP VINDEX](/litedb-docs/sql/ddl/vector_index/drop_vindex.md)，不能混用两种语句。

## 参数

| 参数                | 说明                         |
| ----------------- | -------------------------- |
| `IF EXISTS`       | 可选；索引不存在时返回空操作，不报错         |
| `index_name`      | 要删除的标量索引名称                 |
| `collection_name` | 索引所属集合；必须属于当前 `USE` 选中的数据库 |

## 行为

删除成功后，索引定义从 Catalog 移除，运行时索引也不再参与后续查询和写入维护。正常删除命令的 `affected_rows` 为 `1`；使用 `IF EXISTS` 删除不存在的索引时为 `0`。

列级 `UNIQUE` 创建的隐式唯一索引不能单独删除。尝试删除它会返回错误；删除整个集合时，该索引会随集合一起清理。

不带 `IF EXISTS` 时，目标集合不存在或索引不存在都会报错。`DROP INDEX` 不会删除集合中的记录。

## 示例

```sql
USE demo;

DROP INDEX idx_age ON users;
DROP INDEX IF EXISTS idx_name ON users;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://litedb.gitbook.io/litedb-docs/sql/ddl/scalar_index/drop_index.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
