更新时间:2022-10-22 21:39:08
SELECT current_user; - 当前执行上下文的用户名
SELECT session_user; - 会话用户名
这意味着, session_user
显示您连接的角色, current_user
显示您当前正在运行的角色,例如在调用 SET角色some_other_role
。
I have some application based on Qt library and using QPSQL driver.
In PostreSQL defined a few user roles (e.g: admin, operator, user). My application creates a connection to postgres server under specified user. How can I check the users role?
SELECT current_user; -- user name of current execution context
SELECT session_user; -- session user name
That means, session_user
shows the role you connected with, and current_user
shows the role you are currently operating with, for instance after calling SET role some_other_role
.