zoukankan      html  css  js  c++  java
  • postgresql 对未来的表赋权限

    • 对于未来的表赋权

    --如果想对新增的表有权限还需要赋予未来新增表的权限。
    --用sa新建的表role_a还是没有权限访问。

    --使用sa在schema1创建表test2
    postgres=> c postgres sa
    You are now connected to database "postgres" as user "sa".
    
    postgres=# create table schema1.test2(id int);
    CREATE TABLE
    postgres=# insert into schema1.test2 values(1);
    INSERT 0 1
    --role_a没有权限访问该表,
    postgres=# c postgres role_a;
    You are now connected to database "postgres" as user "role_a".
    postgres=> select * from schema1.test2;
    错误:  permission denied for table test2
    --使用superuser赋权alter default privileges
    postgres=> c postgres sa 
    You are now connected to database "postgres" as user "sa".
    postgres=# alter default privileges in schema schema1 grant select on tables to role_a;
    ALTER DEFAULT PRIVILEGES
    --访问test2还是访问不了,原因是修改了default privileges后,只是对授权之后创建的对象有效
    postgres=> select * from schema1.test2;
    错误:  permission denied for table test2
    
    --再次建test3表
    postgres=# create table schema1.test3(id int);
    CREATE TABLE
    postgres=# insert into schema1.test3 values(1);
    INSERT 0 1
    --role_a可以访问了
    postgres=# c postgres role_a
    You are now connected to database "postgres" as user "role_a".
    postgres=> select * from schema1.test3;
     id 
    ----
      1
    (1 row)
    
    
  • 相关阅读:
    转载:configure生成的文件(1.5.3)《深入理解Nginx》(陶辉)
    现场管理
    02 表扫描
    01 成本的含义
    16 计划稳定性与控制
    14 事务处理
    13 SELECT 以外的内容
    12 索引
    11 半联结 & 反联结
    08 分析函数
  • 原文地址:https://www.cnblogs.com/zhangfx01/p/14367541.html
Copyright © 2011-2022 走看看