PostgreSQL查看当前用户

时间:2021-06-22 18:22:56   收藏:0   阅读:0

方法1

 

select * from current_user;

 

eg: 

kerrydb=> select * from current_user;
 current_user 
--------------
 test
(1 row)

 

方法2

 

select user;

 

eg

kerrydb=> select user;
 user 
------
 test
(1 row)
 
kerrydb=> 

 

 

方法3

 

\c

 

eg

kerrydb=> \c
You are now connected to database "kerrydb" as user "test".

 

此方法只使用与psql命令。

 

方法4

 

\conninfo

 

eg

postgres=# \conninfo
You are connected to database "postgres" as user "postgres" on host "127.0.0.1" at port "5432".

 

方法5

 

 

current_userthe current user identifier

session_userthe current session user identifier

 

postgres=# SELECT session_user, current_user;
 session_user | current_user 
--------------+--------------
 postgres     | postgres
(1 row)
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!