Skip to content

PostgREST error: {PGRST002: Could not query the database for the schema cache}

Last edited: 8/12/2026

在从数据库中删除模式之前,应该先在数据 API 设置中的 公开模式 中移除它。

🌐 A schema should first be removed from the Exposed schemas in Data API settings before dropping it from the database.

如果你在进行 API 请求时遇到 PGRST002 错误,可能是因为数据 API 配置中仍列出的某个模式已经从数据库中删除。如果 PostgREST 的 db_schemas 设置中定义的任何模式缺失,它就无法构建模式缓存。

🌐 If you encounter a PGRST002 error when making API requests, it can be that a schema still listed in the Data API configuration has been dropped from the database. PostgREST cannot build the schema cache if any schema defined in its db_schemas setting is missing.

如何解决这个问题:

  1. 暂时重新创建已删除的模式以恢复 API 连接。
  2. 导航到 项目设置 > 数据 API
  3. 已公开的架构列表中移除目标架构,然后点击保存
  4. 一旦设置保存好,你就可以安全地从数据库中删除这个模式了。

手动覆盖

如果你手动执行了 ALTER ROLE authenticator SET pgrst.db_schemas,仪表板界面将不再管理你的架构。你必须手动更新角色配置:

🌐 If you have manually executed ALTER ROLE authenticator SET pgrst.db_schemas, the Dashboard UI will no longer manage your schemas. You must manually update the role configuration:

1
ALTER ROLE authenticator SET pgrst.db_schemas = 'public, example_schema';
2
NOTIFY pgrst, 'reload config';