Server IP : 103.119.228.120 / Your IP : 3.148.108.201 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/postgresql-9.2.24/html/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >ALTER ROLE</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 9.2.24 Documentation" HREF="index.html"><LINK REL="UP" TITLE="SQL Commands" HREF="sql-commands.html"><LINK REL="PREVIOUS" TITLE="ALTER OPERATOR FAMILY" HREF="sql-alteropfamily.html"><LINK REL="NEXT" TITLE="ALTER SCHEMA" HREF="sql-alterschema.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META NAME="creation" CONTENT="2017-11-06T22:43:11"></HEAD ><BODY CLASS="REFENTRY" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="5" ALIGN="center" VALIGN="bottom" ><A HREF="index.html" >PostgreSQL 9.2.24 Documentation</A ></TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A TITLE="ALTER OPERATOR FAMILY" HREF="sql-alteropfamily.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="sql-commands.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="20%" ALIGN="right" VALIGN="top" ><A TITLE="ALTER SCHEMA" HREF="sql-alterschema.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="SQL-ALTERROLE" ></A >ALTER ROLE</H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN64337" ></A ><H2 >Name</H2 >ALTER ROLE -- change a database role</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN64342" ></A ><H2 >Synopsis</H2 ><PRE CLASS="SYNOPSIS" >ALTER ROLE <TT CLASS="REPLACEABLE" ><I >name</I ></TT > [ [ WITH ] <TT CLASS="REPLACEABLE" ><I >option</I ></TT > [ ... ] ] <SPAN CLASS="phrase" ><SPAN CLASS="PHRASE" >where <TT CLASS="REPLACEABLE" ><I >option</I ></TT > can be:</SPAN ></SPAN > SUPERUSER | NOSUPERUSER | CREATEDB | NOCREATEDB | CREATEROLE | NOCREATEROLE | CREATEUSER | NOCREATEUSER | INHERIT | NOINHERIT | LOGIN | NOLOGIN | REPLICATION | NOREPLICATION | CONNECTION LIMIT <TT CLASS="REPLACEABLE" ><I >connlimit</I ></TT > | [ ENCRYPTED | UNENCRYPTED ] PASSWORD '<TT CLASS="REPLACEABLE" ><I >password</I ></TT >' | VALID UNTIL '<TT CLASS="REPLACEABLE" ><I >timestamp</I ></TT >' ALTER ROLE <TT CLASS="REPLACEABLE" ><I >name</I ></TT > RENAME TO <TT CLASS="REPLACEABLE" ><I >new_name</I ></TT > ALTER ROLE <TT CLASS="REPLACEABLE" ><I >name</I ></TT > [ IN DATABASE <TT CLASS="REPLACEABLE" ><I >database_name</I ></TT > ] SET <TT CLASS="REPLACEABLE" ><I >configuration_parameter</I ></TT > { TO | = } { <TT CLASS="REPLACEABLE" ><I >value</I ></TT > | DEFAULT } ALTER ROLE <TT CLASS="REPLACEABLE" ><I >name</I ></TT > [ IN DATABASE <TT CLASS="REPLACEABLE" ><I >database_name</I ></TT > ] SET <TT CLASS="REPLACEABLE" ><I >configuration_parameter</I ></TT > FROM CURRENT ALTER ROLE <TT CLASS="REPLACEABLE" ><I >name</I ></TT > [ IN DATABASE <TT CLASS="REPLACEABLE" ><I >database_name</I ></TT > ] RESET <TT CLASS="REPLACEABLE" ><I >configuration_parameter</I ></TT > ALTER ROLE <TT CLASS="REPLACEABLE" ><I >name</I ></TT > [ IN DATABASE <TT CLASS="REPLACEABLE" ><I >database_name</I ></TT > ] RESET ALL</PRE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN64365" ></A ><H2 >Description</H2 ><P > <TT CLASS="COMMAND" >ALTER ROLE</TT > changes the attributes of a <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > role. </P ><P > The first variant of this command listed in the synopsis can change many of the role attributes that can be specified in <A HREF="sql-createrole.html" >CREATE ROLE</A >. (All the possible attributes are covered, except that there are no options for adding or removing memberships; use <A HREF="sql-grant.html" >GRANT</A > and <A HREF="sql-revoke.html" >REVOKE</A > 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 <TT CLASS="LITERAL" >CREATEROLE</TT > privilege can change any of these settings, but only for non-superuser and non-replication roles. Ordinary roles can only change their own password. </P ><P > The second variant changes the name of the role. Database superusers can rename any role. Roles having <TT CLASS="LITERAL" >CREATEROLE</TT > privilege can rename non-superuser roles. The current session user cannot be renamed. (Connect as a different user if you need to do that.) Because <TT CLASS="LITERAL" >MD5</TT >-encrypted passwords use the role name as cryptographic salt, renaming a role clears its password if the password is <TT CLASS="LITERAL" >MD5</TT >-encrypted. </P ><P > The remaining variants change a role's session default for a configuration variable, either for all databases or, when the <TT CLASS="LITERAL" >IN DATABASE</TT > clause is specified, only for sessions in the named database. Whenever the role subsequently starts a new session, the specified value becomes the session default, overriding whatever setting is present in <TT CLASS="FILENAME" >postgresql.conf</TT > or has been received from the <TT CLASS="COMMAND" >postgres</TT > command line. This only happens at login time; executing <A HREF="sql-set-role.html" >SET ROLE</A > or <A HREF="sql-set-session-authorization.html" >SET SESSION AUTHORIZATION</A > does not cause new configuration values to be set. Settings set for all databases are overridden by database-specific settings attached to a role. Superusers can change anyone's session defaults. Roles having <TT CLASS="LITERAL" >CREATEROLE</TT > privilege can change defaults for non-superuser roles. Ordinary roles can only set defaults for themselves. Certain configuration variables cannot be set this way, or can only be set if a superuser issues the command. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN64386" ></A ><H2 >Parameters</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="REPLACEABLE" ><I >name</I ></TT ></DT ><DD ><P > The name of the role whose attributes are to be altered. </P ></DD ><DT ><TT CLASS="LITERAL" >SUPERUSER</TT ><BR><TT CLASS="LITERAL" >NOSUPERUSER</TT ><BR><TT CLASS="LITERAL" >CREATEDB</TT ><BR><TT CLASS="LITERAL" >NOCREATEDB</TT ><BR><TT CLASS="LITERAL" >CREATEROLE</TT ><BR><TT CLASS="LITERAL" >NOCREATEROLE</TT ><BR><TT CLASS="LITERAL" >CREATEUSER</TT ><BR><TT CLASS="LITERAL" >NOCREATEUSER</TT ><BR><TT CLASS="LITERAL" >INHERIT</TT ><BR><TT CLASS="LITERAL" >NOINHERIT</TT ><BR><TT CLASS="LITERAL" >LOGIN</TT ><BR><TT CLASS="LITERAL" >NOLOGIN</TT ><BR><TT CLASS="LITERAL" >REPLICATION</TT ><BR><TT CLASS="LITERAL" >NOREPLICATION</TT ><BR><TT CLASS="LITERAL" >CONNECTION LIMIT</TT > <TT CLASS="REPLACEABLE" ><I >connlimit</I ></TT ><BR><TT CLASS="LITERAL" >PASSWORD</TT > <TT CLASS="REPLACEABLE" ><I >password</I ></TT ><BR><TT CLASS="LITERAL" >ENCRYPTED</TT ><BR><TT CLASS="LITERAL" >UNENCRYPTED</TT ><BR><TT CLASS="LITERAL" >VALID UNTIL</TT > '<TT CLASS="REPLACEABLE" ><I >timestamp</I ></TT >'</DT ><DD ><P > These clauses alter attributes originally set by <A HREF="sql-createrole.html" >CREATE ROLE</A >. For more information, see the <TT CLASS="COMMAND" >CREATE ROLE</TT > reference page. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >new_name</I ></TT ></DT ><DD ><P > The new name of the role. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >database_name</I ></TT ></DT ><DD ><P > The name of the database the configuration variable should be set in. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >configuration_parameter</I ></TT ><BR><TT CLASS="REPLACEABLE" ><I >value</I ></TT ></DT ><DD ><P > Set this role's session default for the specified configuration parameter to the given value. If <TT CLASS="REPLACEABLE" ><I >value</I ></TT > is <TT CLASS="LITERAL" >DEFAULT</TT > or, equivalently, <TT CLASS="LITERAL" >RESET</TT > is used, the role-specific variable setting is removed, so the role will inherit the system-wide default setting in new sessions. Use <TT CLASS="LITERAL" >RESET ALL</TT > to clear all role-specific settings. <TT CLASS="LITERAL" >SET FROM CURRENT</TT > saves the session's current value of the parameter as the role-specific value. If <TT CLASS="LITERAL" >IN DATABASE</TT > is specified, the configuration parameter is set or removed for the given role and database only. </P ><P > Role-specific variable settings take effect only at login; <A HREF="sql-set-role.html" >SET ROLE</A > and <A HREF="sql-set-session-authorization.html" >SET SESSION AUTHORIZATION</A > do not process role-specific variable settings. </P ><P > See <A HREF="sql-set.html" >SET</A > and <A HREF="runtime-config.html" >Chapter 18</A > for more information about allowed parameter names and values. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN64469" ></A ><H2 >Notes</H2 ><P > Use <A HREF="sql-createrole.html" >CREATE ROLE</A > to add new roles, and <A HREF="sql-droprole.html" >DROP ROLE</A > to remove a role. </P ><P > <TT CLASS="COMMAND" >ALTER ROLE</TT > cannot change a role's memberships. Use <A HREF="sql-grant.html" >GRANT</A > and <A HREF="sql-revoke.html" >REVOKE</A > to do that. </P ><P > Caution must be exercised when specifying an unencrypted password with this command. The password will be transmitted to the server in cleartext, and it might also be logged in the client's command history or the server log. <A HREF="app-psql.html" ><SPAN CLASS="APPLICATION" >psql</SPAN ></A > contains a command <TT CLASS="COMMAND" >\password</TT > that can be used to change a role's password without exposing the cleartext password. </P ><P > It is also possible to tie a session default to a specific database rather than to a role; see <A HREF="sql-alterdatabase.html" >ALTER DATABASE</A >. If there is a conflict, database-role-specific settings override role-specific ones, which in turn override database-specific ones. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN64483" ></A ><H2 >Examples</H2 ><P > Change a role's password: </P><PRE CLASS="PROGRAMLISTING" >ALTER ROLE davide WITH PASSWORD 'hu8jmn3';</PRE ><P> </P ><P > Remove a role's password: </P><PRE CLASS="PROGRAMLISTING" >ALTER ROLE davide WITH PASSWORD NULL;</PRE ><P> </P ><P > Change a password expiration date, specifying that the password should expire at midday on 4th May 2015 using the time zone which is one hour ahead of <ACRONYM CLASS="ACRONYM" >UTC</ACRONYM >: </P><PRE CLASS="PROGRAMLISTING" >ALTER ROLE chris VALID UNTIL 'May 4 12:00:00 2015 +1';</PRE ><P> </P ><P > Make a password valid forever: </P><PRE CLASS="PROGRAMLISTING" >ALTER ROLE fred VALID UNTIL 'infinity';</PRE ><P> </P ><P > Give a role the ability to create other roles and new databases: </P><PRE CLASS="PROGRAMLISTING" >ALTER ROLE miriam CREATEROLE CREATEDB;</PRE ><P> </P ><P > Give a role a non-default setting of the <A HREF="runtime-config-resource.html#GUC-MAINTENANCE-WORK-MEM" >maintenance_work_mem</A > parameter: </P><PRE CLASS="PROGRAMLISTING" >ALTER ROLE worker_bee SET maintenance_work_mem = 100000;</PRE ><P> </P ><P > Give a role a non-default, database-specific setting of the <A HREF="runtime-config-logging.html#GUC-CLIENT-MIN-MESSAGES" >client_min_messages</A > parameter: </P><PRE CLASS="PROGRAMLISTING" >ALTER ROLE fred IN DATABASE devel SET client_min_messages = DEBUG;</PRE ><P></P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN64502" ></A ><H2 >Compatibility</H2 ><P > The <TT CLASS="COMMAND" >ALTER ROLE</TT > statement is a <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > extension. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN64507" ></A ><H2 >See Also</H2 ><A HREF="sql-createrole.html" >CREATE ROLE</A >, <A HREF="sql-droprole.html" >DROP ROLE</A >, <A HREF="sql-set.html" >SET</A ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="sql-alteropfamily.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="sql-alterschema.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >ALTER OPERATOR FAMILY</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="sql-commands.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ALTER SCHEMA</TD ></TR ></TABLE ></DIV ></BODY ></HTML >