PostgreSQL查不到新建表?
2023-02-25 18:20:33 时间
近期有同学反馈在使用PG数据库的时候,明明之前创建的账号已经授权了查看所有表的权限,为何却查不到新建表?到底该如何授权?
1. 常见授权脚本
创建用户test_user
create user test_user with password 'password';
授权用户使用public schema的权限
grant usage on schema public to test_user;
授权用户查看schema public下的所有表(授权时此库的的所有表,后续新增表不能看到)
grant select on all tables in schema public to test_user;
授权test_user用户查看新创建表的select 权限
alter default privileges in schema public grant select on tables to test_user;
授予指定schema 下所有数据表及序列的权限
grant all privileges on all tables in schema public to test_user;
grant all privileges on all sequences in schema public to test_user;
2. 查看用户权限
很多时候也需要查看用户有哪些权限,因此常见的权限查看脚本如下
查看某用户的系统权限
SELECT * FROM pg_roles WHERE rolname='test_user';
查看某用户的表权限
select * from information_schema.table_privileges where grantee='test_user';
查看某用户的usage权限
select * from information_schema.usage_privileges where grantee='test_user';
查看某用户在存储过程函数的执行权限
select * from information_schema.routine_privileges where grantee='test_user';
查看某用户在某表的列上的权限
select * from information_schema.column_privileges where grantee='test_user';
查看当前用户能够访问的数据类型
select * from information_schema.data_type_privileges ;
查看用户自定义类型上授予的USAGE权限
select * from information_schema.udt_privileges where grantee='test_user';
相关文章
- 超详细的Wireshark使用教程
- 我像“小马过河”一样升级了我的开源系统
- ESLint 配置入门,你学会了吗?
- 通过实战总结的 使用GoFrame小技巧
- Wi-Fi满格,网速却快不起来,咋整啊?
- 先聊聊「内存分配」,再聊聊Go的「逃逸分析」
- 【Go必知必会】错误和异常、CGO、fallthrough
- V8 引擎:基于类型推测的性能优化原理
- PHP转Go,框架选什么?
- 写好剧本直接出片!Google发布首个「讲故事」的视频生成模型
- 智能体觉醒自我意识?DeepMind警告:当心模型「阳奉阴违」
- Meta发布万元VR机皇,小扎在元宇宙里也长腿了!
- Science:600名博士调查,家里太穷,读博更容易迷茫!
- 这盘「大脑」80万细胞,5分钟学会打乒乓球完爆AI!
- 30年来最严!美商务部会议解释对华芯片管制新规,台积电获一年豁免
- 苹果mac万能音视频转换器:Permute 3 for mac中文版v3.9.15
- 5年秘密研发!谷歌3D「魔镜」实测,真人聊天不用「抱脸虫」
- TPUv4开放使用!谷歌新一代TPU性价比有多高?
- 刚刚,华人数学家张益唐宣称攻克Landau-Siegel零点猜想
- 亲戚逼相亲?美国小哥生成了一个AI女友躲避催婚