> 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/15/the-sql-language/functions-and-operators/uuid-functions.md).

# 9.14. UUID Functions

PostgreSQL 提供了一個產成 UUID 的函數：

```
gen_random_uuid () → uuid
```

此函數回傳版本 4（隨機）的 UUID。這是最常用的 UUID 樣式，適用於大多數的應用。

[uuid-ossp](/15/appendixes/additional-supplied-modules/uuid-ossp.md) 模組提供了其他函數，這些函數實作了用於產生成其他 UUID 的標準演算法。

PostgreSQL 還提供了 [Table 9.1](/15/the-sql-language/functions-and-operators/comparison-functions-and-operators.md#table-9-1-comparison-operators) 中列出的用於 UUID 常用的比較運算子。


---

# 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/15/the-sql-language/functions-and-operators/uuid-functions.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.
