> ## 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}/projects/{projectId}/memories/databases/{databaseId}
```

部分更新数据库记忆。未传入的字段保持不变。您可以重命名记忆、修改或清空它的指引，以及绑定、更换或解除它的分析模型。记忆读取的数据源不能更换；要读取另一个数据源，请另建一个记忆。

如果分析模型不在该工作空间中，或者建在与记忆不同的数据源上，请求会被拒绝。

> [!NOTE]
>
> **所需权限：** 项目上的 `project:dbset_modify`

### 路径参数

**workspaceId** `string` *required*

项目所属的工作空间 ID

**projectId** `string` *required*

项目 ID

**databaseId** `string` *required*

数据库记忆 ID

### 请求体

**name** `string`

新的显示名称。传空值会被忽略，因此名称无法清空。

**instruction** `string`

新的回答指引：数据的含义、哪些表重要、内部惯例等。传空字符串可清空指引。[生成数据库记忆指引](https://docs.memorylake.cn/features/memorylake/api-reference/database/database-memories/generate-database-memory-instruction.md)可以为您起草一份。

**analysis\_model\_id** `string`

该记忆要从中获取知识的分析模型 ID。它必须与记忆建在同一个数据源上，且您需要对它有 `analysis_model:read` 权限。传空字符串可解除当前绑定。

```bash Change the instruction theme={null}
curl -X PATCH 'https://app.memorylake.cn/openapi/memorylake/api/v3/workspaces/ws-8001856949ad4f6a5b6226f415ffa877/projects/proj-b93e8d95a8705bcc4ec42a65ba4cc7f8/memories/databases/doc-2e6a9c4f8b1d4a7e9c3b5d8f0a2c4e6b' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "instruction": "All amounts are in US dollars. Answer revenue questions from sales.orders.total_amount, treat created_at as UTC, and join customers on customer_id."
  }'
```

```bash Remove the analysis model theme={null}
curl -X PATCH 'https://app.memorylake.cn/openapi/memorylake/api/v3/workspaces/ws-8001856949ad4f6a5b6226f415ffa877/projects/proj-b93e8d95a8705bcc4ec42a65ba4cc7f8/memories/databases/doc-2e6a9c4f8b1d4a7e9c3b5d8f0a2c4e6b' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "analysis_model_id": ""
  }'
```

### 响应

返回更新后的数据库记忆。

**data** `object`

**数据库记忆对象**

**id** `string`

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

**name** `string`

显示名称

**instruction** `string`

回答针对这个数据库的问题时遵循的指引：数据的含义、哪些表重要、内部惯例等。未设置时为空字符串。

**status** `string`

处理状态：`pending`、`running`、`okay` 或 `error`。变为 `okay` 后记忆即可使用。

**error** `object`

失败详情。仅当 `status` 为 `error` 且上报了失败原因时返回。

**错误详情**

**code** `string`

错误码

**msg** `string`

错误信息

**project\_id** `string`

记忆所属项目的 ID

**db\_datasource\_id** `string`

该记忆读取的数据源

**analysis\_model\_id** `string`

该记忆从中获取知识的分析模型。未绑定时不返回该字段。

**created\_at** `string`

创建时间戳

```json Success (200) theme={null}
{
  "success": true,
  "data": {
    "id": "doc-2e6a9c4f8b1d4a7e9c3b5d8f0a2c4e6b",
    "name": "Sales database",
    "instruction": "All amounts are in US dollars. Answer revenue questions from sales.orders.total_amount, treat created_at as UTC, and join customers on customer_id.",
    "status": "okay",
    "project_id": "proj-b93e8d95a8705bcc4ec42a65ba4cc7f8",
    "db_datasource_id": "dbds-4b8e2f6a1c9d4e7b8a3f5c2d6e9b1a7c",
    "analysis_model_id": "am-9d3f7b1e5a2c4d8f6b0e3a7c9d1f5b2e",
    "created_at": "2026-09-21T09:03:17.482Z"
  }
}
```


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