[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.htmlPostgreSQL数据库中的current_user和session_user
最新推荐文章于 2024-12-10 23:52:54 发布
本文介绍在PostgreSQL数据库中如何使用set role命令来切换当前会话的角色,并展示了current_user和session_user的区别。
1248

被折叠的 条评论
为什么被折叠?



