PostgreSQL 12超级用户postgres访问public schema提示权限拒绝
PostgreSQL 12:执行操作时提示"permission denied for schema public"
执行操作时触发如下错误:
ERROR: permission denied for schema public
已执行的排查与操作
- 当前登录角色为超级用户postgres,已执行授权命令:
GRANT all ON SCHEMA public TO postgres; grant all on all tables in schema "public" to postgres;
- 验证postgres角色权限,执行
\duS+输出:
List of roles Role name | Attributes | Member of | Description ---------------------------+------------------------------------------------------------+--------------------------------------------------------------+------------- postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} |
- 查询
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
相关产品推荐
相关产品推荐

