暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PostgreSQL查不到新建表?

数据库干货铺 2022-11-23
1395
点击上方蓝字关注我

近期有同学反馈在使用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';
                          往期精彩回顾

                          1.  MySQL高可用之MHA集群部署

                          2.  mysql8.0新增用户及加密规则修改的那些事

                          3.  比hive快10倍的大数据查询利器-- presto

                          4.  监控利器出鞘:Prometheus+Grafana监控MySQL、Redis数据库

                          5.  PostgreSQL主从复制--物理复制

                          6.  MySQL传统点位复制在线转为GTID模式复制

                          7.  MySQL敏感数据加密及解密

                          8.  MySQL数据备份及还原(一)

                          9.  MySQL数据备份及还原(二)

                          扫码关注     

                          文章转载自数据库干货铺,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                          评论