pg_db_role_setting
是一个存储运行时配置变量默认值的系统目录表,适用于每个用户/角色和数据库。
pg_db_role_setting
在PostgreSQL 9.0 中添加。
此表在集群中的所有数据库之间共享。
psql
\drds
列出此表存储的每个数据库的角色设置。
按 PostgreSQL 版本定义
pg_db_role_setting (PostgreSQL 17)
Table "pg_catalog.pg_db_role_setting" Column | Type | Collation | Nullable | Default -------------+--------+-----------+----------+--------- setdatabase | oid | | not null | setrole | oid | | not null | setconfig | text[] | C | | Indexes: "pg_db_role_setting_databaseid_rol_index" PRIMARY KEY, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 16)
Table "pg_catalog.pg_db_role_setting" Column | Type | Collation | Nullable | Default -------------+--------+-----------+----------+--------- setdatabase | oid | | not null | setrole | oid | | not null | setconfig | text[] | C | | Indexes: "pg_db_role_setting_databaseid_rol_index" PRIMARY KEY, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 15)
Table "pg_catalog.pg_db_role_setting" Column | Type | Collation | Nullable | Default -------------+--------+-----------+----------+--------- setdatabase | oid | | not null | setrole | oid | | not null | setconfig | text[] | C | | Indexes: "pg_db_role_setting_databaseid_rol_index" PRIMARY KEY, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 14)
Table "pg_catalog.pg_db_role_setting" Column | Type | Collation | Nullable | Default -------------+--------+-----------+----------+--------- setdatabase | oid | | not null | setrole | oid | | not null | setconfig | text[] | C | | Indexes: "pg_db_role_setting_databaseid_rol_index" PRIMARY KEY, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 13)
Table "pg_catalog.pg_db_role_setting" Column | Type | Collation | Nullable | Default -------------+--------+-----------+----------+--------- setdatabase | oid | | not null | setrole | oid | | not null | setconfig | text[] | C | | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 12)
Table "pg_catalog.pg_db_role_setting" Column | Type | Collation | Nullable | Default -------------+--------+-----------+----------+--------- setdatabase | oid | | not null | setrole | oid | | not null | setconfig | text[] | C | | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 11)
Table "pg_catalog.pg_db_role_setting" Column | Type | Collation | Nullable | Default -------------+--------+-----------+----------+--------- setdatabase | oid | | not null | setrole | oid | | not null | setconfig | text[] | | | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 10)
Table "pg_catalog.pg_db_role_setting" Column | Type | Collation | Nullable | Default -------------+--------+-----------+----------+--------- setdatabase | oid | | not null | setrole | oid | | not null | setconfig | text[] | | | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 9.6)
Table "pg_catalog.pg_db_role_setting" Column | Type | Modifiers -------------+--------+----------- setdatabase | oid | not null setrole | oid | not null setconfig | text[] | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 9.5)
Table "pg_catalog.pg_db_role_setting" Column | Type | Modifiers -------------+--------+----------- setdatabase | oid | not null setrole | oid | not null setconfig | text[] | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 9.4)
Table "pg_catalog.pg_db_role_setting" Column | Type | Modifiers -------------+--------+----------- setdatabase | oid | not null setrole | oid | not null setconfig | text[] | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 9.3)
Table "pg_catalog.pg_db_role_setting" Column | Type | Modifiers -------------+--------+----------- setdatabase | oid | not null setrole | oid | not null setconfig | text[] | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 9.2)
Table "pg_catalog.pg_db_role_setting" Column | Type | Modifiers -------------+--------+----------- setdatabase | oid | not null setrole | oid | not null setconfig | text[] | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 9.1)
Table "pg_catalog.pg_db_role_setting" Column | Type | Modifiers -------------+--------+----------- setdatabase | oid | not null setrole | oid | not null setconfig | text[] | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
pg_db_role_setting (PostgreSQL 9.0)
Table "pg_catalog.pg_db_role_setting" Column | Type | Modifiers -------------+--------+----------- setdatabase | oid | not null setrole | oid | not null setconfig | text[] | Indexes: "pg_db_role_setting_databaseid_rol_index" UNIQUE, btree (setdatabase, setrole), tablespace "pg_global" Tablespace: "pg_global"
更改历史记录
- PostgreSQL 9.0
- 添加,替换了
pg_database
列datconfig
和pg_authid
列rolconfig
。(提交 2eda8dfb)
- 添加,替换了
示例
postgres=# SELECT * FROM pg_db_role_setting ; setdatabase | setrole | setconfig -------------+---------+------------------------------------------- 0 | 16384 | {"search_path=app, hstore, public"} 0 | 16385 | {"search_path=admin, users, public"} (2 rows)
内容也可以使用 psql 命令 \drds
显示。
postgres=# \drds List of settings Role | Database | Settings ----------+----------+------------------------------------- app | | search_path=app, hstore, public admin | | search_path=admin, users, public
参考
- PostgreSQL 文档: pg_db_role_setting