You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PostgreSQL用户权限正常却无法在information_schema.tables看到部分表

PostgreSQL 14.5权限问题:用户无法在information_schema.tables中看到全部同schema表

背景信息

  • PostgreSQL版本:14.5
  • 所有表位于单个非postgres数据库,且均属于public schema
  • 已为my_user执行以下授权:
GRANT USAGE ON SCHEMA public TO my_user;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO my_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO my_user;
  • 现象:用户能看到部分表,但有部分表未出现在information_schema.tables中

已执行的排查步骤

  1. 验证缺失表的权限配置:
SELECT table_schema, table_name, grantee, privilege_type
FROM information_schema.role_table_grants
WHERE table_name = 'missing_table';
  1. 确认用户拥有public schema的USAGE权限:
SELECT schema_name, grantee, privilege_type
FROM information_schema.role_usage_grants
WHERE schema_name = 'public';
  1. 对比可见表与缺失表的所有者:
SELECT table_schema, table_name, table_owner
FROM information_schema.tables
WHERE table_name IN ('visible_table', 'missing_table');
  1. 检查用户角色的所有表权限:
SELECT * FROM information_schema.role_table_grants WHERE grantee = 'my_user';

观察到的关键现象

  • 用户可正常查询可见表
  • 用户直接查询缺失表(如SELECT * FROM public.missing_table;)无报错,但这些表未出现在information_schema.tables中

核心疑问

  1. 同schema、相同授权配置下,为何部分表在information_schema.tables中不可见?
  2. 如何进一步排查根本原因?

补充说明

  • 所有表均属于public schema
  • 当前持有数据库管理员权限,可执行任意必要查询或提供更多细节

内容的提问来源于stack exchange,提问作者dorje

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 06:14:59