[postgres@pgserver ~]$ psql psql (10beta2) Type "help" for help. postgres=# select current_user,session_user; current_user | session_user --------------+-------------- postgres | postgres (1 row) postgres=# set role to u_3; SET postgres=> select current_user,session_user; current_user | session_user --------------+-------------- u_3 | postgres (1 row) postgres=> 注意: current_user 是 the current user identifier session_user 是 the current session user identifier ,注:我理解下来,就是启动该session的user。 参考自: https://www.postgresql.org/docs/10/static/sql-set-role.html