How to check role of current PostgreSQL user from

2019-03-21 02:35发布

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?

2条回答
你好瞎i
2楼-- · 2019-03-21 02:54

You can check PostgreSQL user permissions with this query:

SELECT * FROM pg_roles;
查看更多
闹够了就滚
3楼-- · 2019-03-21 02:55

Per documentation:

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.

查看更多
登录 后发表回答