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

# 编辑 Schema 元数据

> 批量编辑数据表和字段的注释，以及字段的索引开关

```
PATCH /openapi/memorylake/api/v3/workspaces/{workspaceId}/db-datasources/{datasourceId}/schema-metadata
```

在一次批量请求中编辑数据表和字段的注释，以及字段的索引开关。每条编辑都用 `target` 指明对象：`table` 编辑修改数据表的注释；`column` 编辑修改字段的注释、是否为字段的值建立语义匹配索引，或者两者都改。

* 不传 `comment` 表示保留当前注释；传空字符串表示清除注释。
* 每条编辑都必须有实际改动。`table` 编辑必须带 `comment`；`column` 编辑必须带 `comment`、`embedding_enabled` 之一或两者。
* 编辑按您发送的顺序逐条应用。如果某条失败，请求返回错误，而它之前的编辑仍然保留。

注释只保存在这个数据源中，不会修改您数据库里的注释，也不会影响基于同一 schema 的其他数据源。当前的值可以通过[列出数据表](https://docs.memorylake.cn/features/memorylake/api-reference/database/datasources/list-tables.md)和[列出字段](https://docs.memorylake.cn/features/memorylake/api-reference/database/datasources/list-columns.md)查看。

> [!NOTE]
>
> **所需权限：** `db_datasource:modify`

### 路径参数

**workspaceId** `string` *required*

工作空间 ID

**datasourceId** `string` *required*

数据源 ID

### 请求体

**items** `array` *required*

要应用的编辑，每次请求 1 到 200 条

**编辑对象**

**items\[].target** `string` *required*

编辑的对象：`table` 或 `column`

**items\[].table\_name** `string` *required*

编辑所针对的数据表。字段编辑也需要它，因为字段是以「某张表的字段」来定位的。

**items\[].column\_name** `string`

要编辑的字段。`target` 为 `column` 时必填。

**items\[].schema\_name** `string`

编辑所针对的 schema。不传时使用这个数据源覆盖的 schema。

**items\[].comment** `string | null`

新的注释。不传表示保留当前注释；传空字符串表示清除注释。`target` 为 `table` 时必填。

**items\[].embedding\_enabled** `boolean | null`

是否为这个字段的值建立语义匹配索引。不传表示保持现状。仅用于 `column` 编辑。

```bash cURL theme={null}
curl -X PATCH 'https://app.memorylake.cn/openapi/memorylake/api/v3/workspaces/ws-8001856949ad4f6a5b6226f415ffa877/db-datasources/dbds-4b8e2f6a1c9d4e7b8a3f5c2d6e9b1a7c/schema-metadata' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "items": [
      {
        "target": "table",
        "table_name": "orders",
        "comment": "One row per customer order"
      },
      {
        "target": "column",
        "table_name": "orders",
        "column_name": "total_amount",
        "comment": "Order total, including tax"
      },
      {
        "target": "column",
        "table_name": "orders",
        "column_name": "created_at",
        "comment": ""
      },
      {
        "target": "column",
        "table_name": "customers",
        "column_name": "city",
        "embedding_enabled": true
      }
    ]
  }'
```

### 响应

**success** `boolean`

表示请求是否成功

**message** `string`

人类可读的状态消息

```json Success (200) theme={null}
{
  "success": true,
  "message": "Operation completed successfully"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.