# 11.11. 索引與排序規則

每個索引欄位只能支援一個排序規則（Collation）。 如果感興趣多個排序規則，則可能需要多個索引。

看看以下語法：

```
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");
```


---

# Agent Instructions: 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:

```
GET https://docs.postgresql.tw/14/the-sql-language/index/indexes-and-collations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
