test=# \c
You are now connected to database "test" as user "postgres9.6".
test=# select current_user,session_user;
current_user | session_user
--------------+--------------
postgres9.6 | postgres9.6
(1 row)
test=# set role a;
SET
test=> select current_user,session_user;
current_user | session_user
--------------+--------------
a | postgres9.6
(1 row)
当用户名中包含特殊字符时,需用单引号引起来:
^
test=> set role postgres9.6;
ERROR: syntax error at or near ".6"
LINE 1: set role postgres9.6;
^
test=> set role 'postgres9.6';
SET
test=# select current_user,session_user;
current_user | session_user
--------------+--------------
postgres9.6 | postgres9.6
(1 row)
You are now connected to database "test" as user "postgres9.6".
test=# select current_user,session_user;
current_user | session_user
--------------+--------------
postgres9.6 | postgres9.6
(1 row)
test=# set role a;
SET
test=> select current_user,session_user;
current_user | session_user
--------------+--------------
a | postgres9.6
(1 row)
当用户名中包含特殊字符时,需用单引号引起来:
^
test=> set role postgres9.6;
ERROR: syntax error at or near ".6"
LINE 1: set role postgres9.6;
^
test=> set role 'postgres9.6';
SET
test=# select current_user,session_user;
current_user | session_user
--------------+--------------
postgres9.6 | postgres9.6
(1 row)