> 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/appendixes/contrib/seg/seg-syntax.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# F.39.2. 語法

## F.39.2. 語法 [#](#seg-syntax) <a href="#seg-syntax" id="seg-syntax"></a>

區間的外部表示法由一個或兩個浮點數組成，兩數之間以範圍運算子（`..` 或 `...`）連接。另外，也可以指定為中心點加減一個偏差值。 也可以一併儲存選用的確定性指示符（`<`、 `>` 或 `~`）。 （不過，所有內建運算子都會忽略確定性指示符。） [表 F.29](#seg-repr-table) 概述允許的表示法；[表 F.30](#seg-input-examples) 列出一些範例。

在[表 F.29](#seg-repr-table) 中，*`x`*、*`y`* 與 *`delta`* 表示浮點數。*`x`* 與 *`y`* 前面可以加上確定性指示符，但 *`delta`* 不可以。

### 表 F.29. `seg` 外部表示法 [#](#seg-repr-table) <a href="#seg-repr-table" id="seg-repr-table"></a>

| *`x`*                      | 單一值（長度為零的區間）                                |
| -------------------------- | ------------------------------------------- |
| *`x`*` ``..`` `*`y`*       | 從 *`x`* 到 *`y`* 的區間                         |
| *`x`*` ``(+-)`` `*`delta`* | 從 *`x`* - *`delta`* 到 *`x`* + *`delta`* 的區間 |
| *`x`*` ``..`               | 下界為 *`x`* 的開放區間                             |
| `..`` `*`x`*               | 上界為 *`x`* 的開放區間                             |

<br>

### 表 F.30. 有效的 `seg` 輸入範例 [#](#seg-input-examples) <a href="#seg-input-examples" id="seg-input-examples"></a>

| `5.0`            | 建立長度為零的線段（也可以說是一個點）                               |
| ---------------- | ------------------------------------------------- |
| `~5.0`           | 建立長度為零的線段，並在資料中記錄 `~`。`~` 會被 `seg` 運算忽略，但會作為註記保留。 |
| `<5.0`           | 建立位於 5.0 的點。`<` 會被忽略，但會作為註記保留。                    |
| `>5.0`           | 建立位於 5.0 的點。`>` 會被忽略，但會作為註記保留。                    |
| `5(+-)0.3`       | 建立區間 `4.7 .. 5.3`。 請注意，`(+-)` 表示法不會被保留。           |
| `50 ..`          | 所有大於或等於 50 的值                                     |
| `.. 0`           | 所有小於或等於 0 的值                                      |
| `1.5e-2 .. 2E-2` | 建立區間 `0.015 .. 0.02`                              |
| `1 ... 2`        | 與 `1...2`、`1 .. 2` 或 `1..2` 相同 （範圍運算子前後的空白會被忽略）   |

<br>

由於 `...` 運算子在各種資料來源中廣泛使用，因此允許以它作為 `..` 運算子的另一種寫法。可惜的是，這會造成剖析上的歧義：無法確定 `0...23` 中的上界是指 `23` 還是 `0.23`。 解決方式是要求 `seg` 輸入中的所有數字，在小數點之前至少要有一位數字。

作為合理性檢查，`seg` 會拒絕下界大於上界的區間，例如 `5 .. 2`。

[返回 F.39. seg — 線段或浮點數區間的資料型別](https://docs.postgresql.tw/19/appendixes/contrib/seg.md#seg)

***

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


---

# 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/appendixes/contrib/seg/seg-syntax.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.
