> ## 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.

# 更新数据源

> 修改数据源的名称、描述或数据表筛选规则

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

部分更新数据源。未传入的字段保持不变。连接和 schema 在创建时就已确定，这里不能修改；如需覆盖另一个 schema，请[另建一个数据源](https://docs.memorylake.cn/features/memorylake/api-reference/database/datasources/create-datasource.md)。

`table_filter_rule` 决定构建时哪些数据表进入索引。修改它之后，请重新[构建索引](https://docs.memorylake.cn/features/memorylake/api-reference/database/datasources/build-datasource-index.md)，让索引按新规则生成。

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

### 路径参数

**workspaceId** `string` *required*

工作空间 ID

**datasourceId** `string` *required*

数据源 ID

### 请求体

**name** `string`

显示名称

**description** `string`

自由格式的描述

**table\_filter\_rule** `string`

正则表达式，决定 schema 中哪些数据表进入索引。`.*` 表示全部数据表。

```bash Rename theme={null}
curl -X PATCH 'https://app.memorylake.cn/openapi/memorylake/api/v3/workspaces/ws-8001856949ad4f6a5b6226f415ffa877/db-datasources/dbds-4b8e2f6a1c9d4e7b8a3f5c2d6e9b1a7c' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Sales",
    "description": "Orders and customers, refreshed nightly"
  }'
```

```bash Index only some tables theme={null}
curl -X PATCH 'https://app.memorylake.cn/openapi/memorylake/api/v3/workspaces/ws-8001856949ad4f6a5b6226f415ffa877/db-datasources/dbds-4b8e2f6a1c9d4e7b8a3f5c2d6e9b1a7c' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "table_filter_rule": "^(orders|customers)$"
  }'
```

### 响应

返回更新后的数据源。

**data** `object`

**数据源对象**

**id** `string`

数据源标识符，请把它当作不透明字符串处理。

**name** `string`

显示名称

**description** `string`

自由格式的描述

**schemas** `array`

这个数据源覆盖的 schema。目前只包含一项，且不能修改。

**workspace\_id** `string`

这个数据源所属的工作空间

**db\_connection\_id** `string`

这个数据源读取数据所用的连接

**custom\_id** `string`

您为这个数据源设置的自定义标识符（如果设置过）

**table\_filter\_rule** `string`

正则表达式，决定 schema 中哪些数据表进入索引。`.*` 表示全部数据表。

**database\_count** `integer`

当前使用这个数据源的数据库记忆数量

**build\_version** `string`

最近一次构建完成的索引版本。首次构建完成之前为空。

**building\_version** `string`

正在构建的索引版本。没有构建在进行时为空。

**data\_version** `string`

数据版本，用于判断索引是否最新。当它非空且与 `build_version` 不同时，说明索引落后于数据，需要重新构建。

**created\_at** `string`

创建时间戳

**updated\_at** `string`

最后更新时间戳

```json Success (200) theme={null}
{
  "success": true,
  "data": {
    "id": "dbds-4b8e2f6a1c9d4e7b8a3f5c2d6e9b1a7c",
    "name": "Sales",
    "description": "Orders and customers, refreshed nightly",
    "schemas": ["sales"],
    "workspace_id": "ws-8001856949ad4f6a5b6226f415ffa877",
    "db_connection_id": "dbconn-7c1e9a4b2d6f4a8e9b3c5d7f1a2b4c6d",
    "custom_id": "sales-ds",
    "table_filter_rule": ".*",
    "database_count": 1,
    "build_version": "20260921082748374",
    "building_version": "",
    "data_version": "",
    "created_at": "2026-09-18T07:42:43.299Z",
    "updated_at": "2026-09-22T02:10:36.415Z"
  }
}
```


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