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

PostgreSQL 12超级用户postgres访问public schema提示权限拒绝

PostgreSQL 12:执行操作时提示"permission denied for schema public"

执行操作时触发如下错误:

ERROR:  permission denied for schema public

已执行的排查与操作

  1. 当前登录角色为超级用户postgres,已执行授权命令:
GRANT all ON SCHEMA public TO postgres;
grant all on all tables in schema "public" to postgres;
  1. 验证postgres角色权限,执行\duS+输出:
List of roles
         Role name         |                         Attributes                         |                          Member of                           | Description 
---------------------------+------------------------------------------------------------+--------------------------------------------------------------+-------------
 postgres                  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}                                                           | 
  1. 查询wms_zone表权限,确认postgres拥有INSERT等权限:
    执行SQL:
SELECT *                                                                                               
FROM information_schema.role_table_grants 
WHERE grantee ='postgres' and table_name='wms_zone';

返回结果:

grantor  | grantee  | table_catalog | table_schema | table_name | privilege_type | is_grantable | with_hierarchy 
----------+----------+---------------+--------------+------------+----------------+--------------+----------------
 sapphire | postgres | table1        | public       | wms_zone   | TRIGGER        | YES          | NO
 sapphire | postgres | table1        | public       | wms_zone   | REFERENCES     | YES          | NO
 sapphire | postgres | table1        | public       | wms_zone   | TRUNCATE       | YES          | NO
 sapphire | postgres | table1        | public       | wms_zone   | DELETE         | YES          | NO
 sapphire | postgres | table1        | public       | wms_zone   | UPDATE         | YES          | NO
 sapphire | postgres | table1        | public       | wms_zone   | SELECT         | YES          | YES
 sapphire | postgres | table1        | public       | wms_zone   | INSERT         | YES          | NO

更新信息

更新:向同一数据库、同一public schema下的其他表插入数据可正常执行。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 09:01:01