SET SESSION AUTHORIZATION 中文man页面

系统
这条命令把当前 SQL 会话环境里的会话用户标识和当前用户标识设置为 username。 这个用户名可以写成一个标识符或者一个字串文本。 使用这个命令,我们可以临时变成一个非特权用户,稍后再切换回超级用户。

NAME

SET SESSION AUTHORIZATION - 为当前会话设置会话用户标识符和当前用户标识符

SYNOPSIS

SET [ SESSION | LOCAL ] SESSION AUTHORIZATION username
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
RESET SESSION AUTHORIZATION

DESCRIPTION 描述


 这条命令把当前 SQL 会话环境里的会话用户标识和当前用户标识设置为 username。 这个用户名可以写成一个标识符或者一个字串文本。 使用这个命令,我们可以临时变成一个非特权用户,稍后再切换回超级用户。


 会话用户标识符一开始设置为(可能经过认证的)客户端提供的用户名。 当前用户标识符通常等于会话用户标识符, 但是可能在 "setuid" 的环境里或者类似的机制里临时改变。 当前用户标识符和权限检查相关。


 只有在初始会话用户(认证了的用户)有超级用户权限的时候,会话用户标识符才能改变。 否则,只有在指定了被认证的用户名的情况下,系统才接受该命令。

SESSION 和 LOCAL 修饰词和普通 SET [set(7)] 命令里的作用相同。

DEFAULT 和 RESET 形式重置会话和当前用户标识符为初始认证的用户名。这些形式可以为任何用户执行。  

EXAMPLES 例子

SELECT SESSION_USER, CURRENT_USER;

 session_user | current_user 
--------------+--------------
 peter        | peter

SET SESSION AUTHORIZATION 'paul';

SELECT SESSION_USER, CURRENT_USER;

 session_user | current_user 
--------------+--------------
 paul         | paul

COMPATIBILITY 兼容性


 SQL 标准允许一些其它的表达式出现在文本 username  的位置上,不过这个东西实际上并不重要。 PostgreSQL 允许标识符语法 ("username"),而 SQL 不允许。 SQL 不允许在一个事务的过程中用这条命令; PostgreSQL 没有这个限制,因为没有什么理由不允许这样用。 标准中表示执行这条命令的权限要求是具体实现定义的。  

#p#

NAME

SET SESSION AUTHORIZATION - set the session user identifier and the current user identifier of the current session

SYNOPSIS

SET [ SESSION | LOCAL ] SESSION AUTHORIZATION username
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
RESET SESSION AUTHORIZATION

DESCRIPTION

This command sets the session user identifier and the current user identifier of the current SQL-session context to be username. The user name may be written as either an identifier or a string literal. Using this command, it is possible, for example, to temporarily become an unprivileged user and later switch back to become a superuser.

The session user identifier is initially set to be the (possibly authenticated) user name provided by the client. The current user identifier is normally equal to the session user identifier, but may change temporarily in the context of ``setuid'' functions and similar mechanisms. The current user identifier is relevant for permission checking.

The session user identifier may be changed only if the initial session user (the authenticated user) had the superuser privilege. Otherwise, the command is accepted only if it specifies the authenticated user name.

The SESSION and LOCAL modifiers act the same as for the regular SET [set(7)] command.

The DEFAULT and RESET forms reset the session and current user identifiers to be the originally authenticated user name. These forms may be executed by any user.  

EXAMPLES

SELECT SESSION_USER, CURRENT_USER;

 session_user | current_user 
--------------+--------------
 peter        | peter

SET SESSION AUTHORIZATION 'paul';

SELECT SESSION_USER, CURRENT_USER;

 session_user | current_user 
--------------+--------------
 paul         | paul

COMPATIBILITY

The SQL standard allows some other expressions to appear in place of the literal username which are not important in practice. PostgreSQL allows identifier syntax ("username"), which SQL does not. SQL does not allow this command during a transaction; PostgreSQL does not make this restriction because there is no reason to. The privileges necessary to execute this command are left implementation-defined by the standard.

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 17:50:19

SET中文man

2011-08-24 18:02:22

SET TRANSAC中文man

2011-08-24 17:53:08

SET CONSTRA中文man

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-25 15:39:42

fcloseall中文man

2011-08-25 15:00:15

cfgetispeed中文man

2011-08-19 18:35:50

issue中文man

2011-08-25 17:03:51

pclose中文man

2011-08-25 17:40:25

setvbuf中文man

2011-08-23 14:21:16

poweroff中文man

2011-08-24 15:52:59

intro中文man

2011-08-23 13:40:31

2011-08-25 17:24:54

puts中文man

2011-08-25 18:34:55

ungetc中文man

2011-08-23 10:03:40

useradd中文man

2011-08-23 10:29:02

chpasswd中文man

2011-08-23 10:34:22

convertquot中文man
点赞
收藏

51CTO技术栈公众号