alter_role.7

来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 195 行

7
195
字号
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "ALTER ROLE" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMEALTER ROLE \- change a database role.SH SYNOPSIS.sp.nfALTER ROLE \fIname\fR [ [ WITH ] \fIoption\fR [ ... ] ]where \fIoption\fR can be:          SUPERUSER | NOSUPERUSER    | CREATEDB | NOCREATEDB    | CREATEROLE | NOCREATEROLE    | CREATEUSER | NOCREATEUSER    | INHERIT | NOINHERIT    | LOGIN | NOLOGIN    | CONNECTION LIMIT \fIconnlimit\fR    | [ ENCRYPTED | UNENCRYPTED ] PASSWORD '\fIpassword\fR'    | VALID UNTIL '\fItimestamp\fR' ALTER ROLE \fIname\fR RENAME TO \fInewname\fRALTER ROLE \fIname\fR SET \fIconfiguration_parameter\fR { TO | = } { \fIvalue\fR | DEFAULT }ALTER ROLE \fIname\fR RESET \fIconfiguration_parameter\fR.sp.fi.SH "DESCRIPTION".PP\fBALTER ROLE\fR changes the attributes of aPostgreSQL role..PPThe first variant of this command listed in the synopsis can changemany of the role attributes that can be specified in CREATE ROLE [\fBcreate_role\fR(7)].(All the possible attributes are covered,except that there are no options for adding or removing memberships; useGRANT [\fBgrant\fR(7)] andREVOKE [\fBrevoke\fR(7)] for that.)Attributes not mentioned in the command retain their previous settings.Database superusers can change any of these settings for any role.Roles having CREATEROLE privilege can change any of thesesettings, but only for non-superuser roles.Ordinary roles can only change their own password..PPThe second variant changes the name of the role.Database superusers can rename any role.Roles having CREATEROLE privilege can rename non-superuserroles.The current session user cannot be renamed.(Connect as a different user if you need to do that.)Because MD5-encrypted passwords use the role name ascryptographic salt, renaming a role clears its password if thepassword is MD5-encrypted..PPThe third and the fourth variant change a role's session default fora specified configuration variable. Whenever the role subsequentlystarts a new session, the specified value becomes the session default,overriding whatever setting is present in \fIpostgresql.conf\fRor has been received from the \fBpostgres\fR command line.(For a role without LOGIN privilege, session defaults haveno effect.)Ordinary roles can change their own session defaults.Superusers can change anyone's session defaults.Roles having CREATEROLE privilege can change defaults fornon-superuser roles.Certain variables cannot be set this way, or can only beset if a superuser issues the command..SH "PARAMETERS".TP\fB\fIname\fB\fRThe name of the role whose attributes are to be altered..TP\fBSUPERUSER\fR.TP\fBNOSUPERUSER\fR.TP\fBCREATEDB\fR.TP\fBNOCREATEDB\fR.TP\fBCREATEROLE\fR.TP\fBNOCREATEROLE\fR.TP\fBCREATEUSER\fR.TP\fBNOCREATEUSER\fR.TP\fBINHERIT\fR.TP\fBNOINHERIT\fR.TP\fBLOGIN\fR.TP\fBNOLOGIN\fR.TP\fBCONNECTION LIMIT \fIconnlimit\fB\fR.TP\fBPASSWORD \fIpassword\fB\fR.TP\fBENCRYPTED\fR.TP\fBUNENCRYPTED\fR.TP\fBVALID UNTIL '\fItimestamp\fB'\fRThese clauses alter attributes originally set byCREATE ROLE [\fBcreate_role\fR(7)]. For more information, see the\fBCREATE ROLE\fR reference page..TP\fB\fInewname\fB\fRThe new name of the role..TP\fB\fIconfiguration_parameter\fB\fR.TP\fB\fIvalue\fB\fRSet this role's session default for the specified configurationparameter to the given value. If\fIvalue\fR is DEFAULTor, equivalently, RESET is used, therole-specific variable setting is removed, so the role willinherit the system-wide default setting in new sessions. UseRESET ALL to clear all role-specific settings.See SET [\fBset\fR(7)] and in the documentation for more information about allowedparameter names and values..SH "NOTES".PPUse CREATE ROLE [\fBcreate_role\fR(7)]to add new roles, and DROP ROLE [\fBdrop_role\fR(7)] to remove a role..PP\fBALTER ROLE\fR cannot change a role's memberships.Use GRANT [\fBgrant\fR(7)] andREVOKE [\fBrevoke\fR(7)]to do that..PPCaution must be exercised when specifying an unencrypted passwordwith this command. The password will be transmitted to the serverin cleartext, and it might also be logged in the client's commandhistory or the server log. psql [\fBpsql\fR(1)] contains a command\fB\\password\fR that can be used to safely change arole's password..PPIt is also possible to tie asession default to a specific database rather than to a role; seeALTER DATABASE [\fBalter_database\fR(7)].Role-specific settings override database-specificones if there is a conflict..SH "EXAMPLES".PPChange a role's password:.sp.nfALTER ROLE davide WITH PASSWORD 'hu8jmn3';.sp.fi.PPChange a password expiration date, specifying that the passwordshould expire at midday on 4th May 2015 usingthe time zone which is one hour ahead of UTC:.sp.nfALTER ROLE chris VALID UNTIL 'May 4 12:00:00 2015 +1';.sp.fi.PPMake a password valid forever:.sp.nfALTER ROLE fred VALID UNTIL 'infinity';.sp.fi.PPGive a role the ability to create other roles and new databases:.sp.nfALTER ROLE miriam CREATEROLE CREATEDB;.sp.fi.PPGive a role a non-default setting of themaintenance_work_mem parameter:.sp.nfALTER ROLE worker_bee SET maintenance_work_mem = 100000;.sp.fi.SH "COMPATIBILITY".PPThe \fBALTER ROLE\fR statement is aPostgreSQL extension..SH "SEE ALSO"CREATE ROLE [\fBcreate_role\fR(7)], DROP ROLE [\fBdrop_role\fR(l)], SET [\fBset\fR(l)]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?