表空间
- PanWeiDB 自带了两个表空间:pg_default 和 pg_global。
- 默认表空间 pg_default:用来存储非共享系统表、用户表、用户表 index、临时表、临时表 index、内部临时表的默认表空间。对应存储目录为实例数据目录下的 base 目录。
- 共享表空间 pg_global:用来存放共享系统表的表空间。对应存储目录为实例数据目录下的 global 目录
postgres=# \db
List of tablespaces
Name | Owner | Location
------------+-------+----------
pg_default | omm |
pg_global | omm |
(2 rows)
postgres=# select oid,spcname from pg_tablespace;
oid | spcname
------+------------
1663 | pg_default
1664 | pg_global
(2 rows)
- 查看主机上对应的目录
[omm@pgdb1 data]$ pwd
/database/panweidb/data
[omm@pgdb1 data]$ ll -d base/
drwx------ 9 omm dbgrp 97 Apr 16 14:05 base/
[omm@pgdb1 data]$ ll -d global/
drwx------ 3 omm dbgrp 4096 Mar 24 15:52 global/
共享系统表
- 根据pg_class表的reltablespace列,来判断是不是共享系统表
select * from pg_class where reltablespace=1664;
- 查询某些表是不是共享表
PanWeiDB=# select relname,relnamespace,reltablespace from pg_class where relname='pg_authid';
relname | relnamespace | reltablespace
-----------+--------------+---------------
pg_authid | 11 | 1664
(1 row)
PanWeiDB=# select relname,relnamespace,reltablespace from pg_class where relname='role_table_grants';
relname | relnamespace | reltablespace
-------------------+--------------+---------------
role_table_grants | 14498 | 0
(1 row)
- role_table_grants表是非共享的,因此当查询某个用户的授权时,需要每个库都查询
PanWeiDB=# SELECT grantee,table_schema,table_name, string_agg( privilege_type,', ' ) as privilege_type FROM information_schema.role_table_grants where grantee='u1' group by table_name,table_schema,grantee;
grantee | table_schema | table_name | privilege_type
---------+--------------+------------+----------------
(0 rows)
db1=# SELECT grantee,table_schema,table_name, string_agg( privilege_type,', ' ) as privilege_type FROM information_schema.role_table_grants where grantee='u1' group by table_name,table_schema,grantee;
grantee | table_schema | table_name | privilege_type
---------+--------------+------------+----------------
u1 | public | t1 | INSERT, SELECT
(1 row)
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




