1postgres=# grant select on all tables in schema test TO readonly ;
session 2: readonly用户查询 t1 表
postgres=> select * from test.t1;
empno | ename | job | mgr | hiredate | sal | comm | deptno
——-+——–+———–+——+————+———+———+——–
7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30
7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30
7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | | 20
7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30
7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | | 30
7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | | 10
7839 | KING | PRESIDENT | | 1981-11-17 | 5000.00 | | 10
7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30
7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | | 30
7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | | 20
7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | | 10
7788 | test | ANALYST | 7566 | 1982-12-09 | 3000.00 | | 20
7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | | 20
1111 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | | 20
(14 rows)
session1 :postgres用户的test模式下创建新表 t2
postgres=# create table test.t2 as select * from test.emp;SELECT 14
session 2:readonly用户查询 t2 表权限不足
【postgresql影子用户实践场景分析】postgres=> select * from test.t2 ;ERROR: permission denied for table t2
session 1:再次赋予 grant select on all tables
1postgres=# grant select on all tables in schema test TO readonly ;
session 2:readonly用户又可以查看 T2 表
postgres=> select * from test.t2 ;
empno | ename | job | mgr | hiredate | sal | comm | deptno
——-+——–+———–+——+————+———+———+——–
7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30
7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30
7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | | 20
7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30
7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | | 30
7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | | 10
7839 | KING | PRESIDENT | | 1981-11-17 | 5000.00 | | 10
7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30
7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | | 30
7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | | 20
7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | | 10
- 如何将postgresql数据库表内数据导出为excel格式
- PostgreSQL 数据库跨版本升级常用方案解析
- PostgreSQL ROW_NUMBER OVER()的用法说明
- PostgreSQL 添加各种约束语法的操作
- postgresql 中的序列nextval详解
- PostgreSQL 序列绑定字段与不绑定字段的区别说明
- PostgreSQL字符切割:substring函数的用法说明
- PostgreSQL 字符串处理与日期处理操作
- postgresql 中的to_char常用操作
- postgresql 中position函数的性能详解