postgresql全局系统表pg_db_role_setting记录不同用户,在不同的数据库中配置run-time configuration variables(运行时参数)。比较常用情况是,跟进某一个用户,在某个库的行为时,可以设置日志水平为mod,而全局的日志水平是DDL,具体用法:(超级用户设置)
postgres=#alterrolemy_uindatabasepostgressetlog_statement='mod'; ALTERROLE
[postgres@vm1_210_3~]$psql-Umy_u-dpostgres psql(9.4.1) Type"help"forhelp. postgres=>\c Youarenowconnectedtodatabase"postgres"asuser"my_u". postgres=>showlog_statement; log_statement --------------- mod (1row) postgres=>\cmy_db Youarenowconnectedtodatabase"my_db"asuser"my_u". my_db=>showlog_statement; log_statement --------------- ddl (1row)
查询pg_db_role_setting
my_db=>select*frompg_db_role_setting; setdatabase|setrole|setconfig -------------+---------+--------------------- 13003|16384|{log_statement=mod} (1row)