> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> 用于控制 RESTORE 查询从备份中恢复哪些类别对象的设置。

# 恢复设置

[`RESTORE`](/docs/zh/concepts/features/backup-restore/overview#syntax) 查询可在其 `SETTINGS` 子句中指定设置，以控制从备份中读取哪些类别的对象。本页面介绍用于选择恢复内容的设置：表数据、访问实体和用户自定义函数。

<div id="structure-only">
  ## `structure_only`
</div>

类型：`Bool`。默认值：`false`。

设置为 `true` 时，将仅从备份中读取 `CREATE` 查询，而不读取恢复对象的
内容。这是一项便捷设置，会将以下三个类别设置的实际默认值均设为 `false`：

* `restore_table_data`
* `restore_access_entities`
* `restore_functions`

<div id="restore-table-data">
  ## `restore_table_data`
</div>

类型：`Bool`。可选；未设置时，默认值为 `!structure_only` (即除非设置了 `structure_only`，否则为 `true`) 。

是否恢复表数据。显式设置时会覆盖
`structure_only`：即使 `structure_only=true`，设为 `true` 仍会恢复表数据；
即使未设置 `structure_only`，设为 `false` 也会跳过表数据。

<div id="restore-access-entities">
  ## `restore_access_entities`
</div>

类型：`Bool`。可选；未设置时，默认为 `!structure_only`。

是否恢复访问实体，包括用户、角色、profile、行策略和配额。
显式设置此项时，会覆盖 `structure_only`。

<div id="restore-functions">
  ## `restore_functions`
</div>

类型：`Bool`。可选；未设置时，默认为 `!structure_only`。

是否恢复用户自定义函数。显式设置时，将覆盖
`structure_only`。

<div id="effective-behavior">
  ## 实际行为
</div>

当某个类别对应的设置为 `true` 时，便会恢复该类别。若未指定某个类别的
设置，其值将由 `structure_only` 决定：默认情况下三者均为
`true`；当 `structure_only=true` 时，三者均变为 `false`。

| `structure_only` | 未设置 `restore_*` | `restore_* = true` | `restore_* = false` |
| :--------------: | :-------------: | :----------------: | :-----------------: |
|      `false`     |       已恢复       |         已恢复        |         已跳过         |
|      `true`      |       已跳过       |         已恢复        |         已跳过         |

这与旧版本完全向后兼容：未设置任何新设置的 `RESTORE` 查询，其行为与此前完全一致。

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

还原表定义和访问实体，但不还原表数据，例如可用于搭建测试环境，或在不复制数据的情况下重放查询：

```sql theme={null}
RESTORE ALL FROM backup_name
SETTINGS structure_only = true, restore_access_entities = true
```

仅还原表数据，不重新创建访问实体或用户自定义
函数：

```sql theme={null}
RESTORE ALL FROM backup_name
SETTINGS structure_only = true, restore_table_data = true
```

还原除用户自定义函数外的所有内容：

```sql theme={null}
RESTORE ALL FROM backup_name
SETTINGS restore_functions = false
```
