set_role.7
来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 91 行
7
91 行
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "SET ROLE" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMESET ROLE \- set the current user identifier of the current session.SH SYNOPSIS.sp.nfSET [ SESSION | LOCAL ] ROLE \fIrolename\fRSET [ SESSION | LOCAL ] ROLE NONERESET ROLE.sp.fi.SH "DESCRIPTION".PPThis command sets the current useridentifier of the current SQL session to be \fIrolename\fR. The role name may bewritten as either an identifier or a string literal.After \fBSET ROLE\fR, permissions checking for SQL commandsis carried out as though the named role were the one that had loggedin originally..PPThe specified \fIrolename\fRmust be a role that the current session user is a member of.(If the session user is a superuser, any role can be selected.).PPThe SESSION and LOCAL modifiers act the sameas for the regular SET [\fBset\fR(7)]command..PPThe NONE and RESET forms reset the currentuser identifier to be the current session user identifier.These forms may be executed by any user..SH "NOTES".PPUsing this command, it is possible to either add privileges or restrictone's privileges. If the session user role has the INHERITSattribute, then it automatically has all the privileges of every role thatit could \fBSET ROLE\fR to; in this case \fBSET ROLE\fReffectively drops all the privileges assigned directly to the session userand to the other roles it is a member of, leaving only the privilegesavailable to the named role. On the other hand, if the session user rolehas the NOINHERITS attribute, \fBSET ROLE\fR drops theprivileges assigned directly to the session user and instead acquires theprivileges available to the named role..PPIn particular, when a superuser chooses to \fBSET ROLE\fR to anon-superuser role, she loses her superuser privileges..PP\fBSET ROLE\fR has effects comparable toSET SESSION AUTHORIZATION [\fBset_session_authorization\fR(7)], but the privilegechecks involved are quite different. Also,\fBSET SESSION AUTHORIZATION\fR determines which roles areallowable for later \fBSET ROLE\fR commands, whereas changingroles with \fBSET ROLE\fR does not change the set of rolesallowed to a later \fBSET ROLE\fR..PP\fBSET ROLE\fR cannot be used within aSECURITY DEFINER function..SH "EXAMPLES".sp.nfSELECT SESSION_USER, CURRENT_USER; session_user | current_user --------------+-------------- peter | peterSET ROLE 'paul';SELECT SESSION_USER, CURRENT_USER; session_user | current_user --------------+-------------- peter | paul.sp.fi.SH "COMPATIBILITY".PPPostgreSQLallows identifier syntax ("rolename"), whilethe SQL standard requires the role name to be written as a stringliteral. SQL does not allow this command during a transaction;PostgreSQL does not make thisrestriction because there is no reason to.The SESSION and LOCAL modifiers are aPostgreSQL extension, as is theRESET syntax..SH "SEE ALSO"SET SESSION AUTHORIZATION [\fBset_session_authorization\fR(7)]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?