> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/the-sql-language/indexes/indexes-collations.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 11.11. 索引與定序

### 11.11. 索引與定序 [#](#indexes-collations) <a href="#indexes-collations" id="indexes-collations"></a>

每個索引欄位只能支援一種定序。如果需要多種定序，可能必須建立多個索引。

考慮下列陳述式：

```

CREATE TABLE test1c (
    id integer,
    content varchar COLLATE "x"
);

CREATE INDEX test1c_content_index ON test1c (content);
```

索引會自動使用底層欄位的定序。因此，下列形式的查詢：

```

SELECT * FROM test1c WHERE content > constant;
```

可以使用此索引，因為比較運算預設會使用欄位的定序。不過，此索引無法加速涉及其他定序的查詢。例如，如果也需要下列形式的查詢：

```

SELECT * FROM test1c WHERE content > constant COLLATE "y";
```

就可以另外建立支援 `"y"` 定序的索引，如下所示：

```

CREATE INDEX test1c_content_y_index ON test1c (content COLLATE "y");
```

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/indexes-collations.html)（原文版本：18.6；核對日期：2026-09-07）


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/the-sql-language/indexes/indexes-collations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
