> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-fbfa8bee.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 包含所有表中现有约束信息的系统表。

# system.constraints

<div id="description">
  ## 描述
</div>

包含所有表中现有约束的信息。

在[临时表](/zh/reference/statements/create/table#temporary-tables)上定义的约束，只有在创建它们的会话中才会显示在 `system.constraints` 中。它们的 `database` 字段为空。

<div id="columns">
  ## 列
</div>

* `database` ([String](/zh/reference/data-types/index)) — 数据库名称。
* `table` ([String](/zh/reference/data-types/index)) — 表名。
* `name` ([String](/zh/reference/data-types/index)) — 约束名称。
* `type` ([Enum8('CHECK' = 0, 'ASSUME' = 1)](/zh/reference/data-types/index)) — 约束类型。
* `expression` ([String](/zh/reference/data-types/index)) — 约束表达式。

<div id="example">
  ## 示例
</div>

```sql theme={null}
SELECT * FROM system.constraints LIMIT 2 FORMAT Vertical;
```

```text theme={null}
Row 1:
──────
database:    default
table:       hits
name:        check_hits
type:        CHECK
expression:  CounterID > 0

Row 2:
──────
database:    default
table:       hits
name:        assume_positive
type:        ASSUME
expression:  WatchID > 0
```
