alter_user 中文man页面

系统
ALTER USER 用于更改用户的 PostgreSQL 帐号的属性。 没有在该命令中出现的属性保持原值。

NAME

ALTER USER - 改变数据库用户帐号

SYNOPSIS

ALTER USER name [ [ WITH ] option [ ... ] ]

where option can be:

    [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' 
    | CREATEDB | NOCREATEDB
    | CREATEUSER | NOCREATEUSER 
    | VALID UNTIL 'abstime'

ALTER USER name RENAME TO newname

ALTER USER name SET parameter { TO | = } { value | DEFAULT }
ALTER USER name RESET parameter

DESCRIPTION 描述

ALTER USER 用于更改用户的 PostgreSQL 帐号的属性。 没有在该命令中出现的属性保持原值。


 这条命令模式中的***个变种修改某些全局用户权限和认证设置。 (见下文获取细节。)只有数据库超级用户可以用这条命令改变这些权限和使口令失效。普通用户只能修改它们自己的口令。


 第二个变种改变用户的名字。只有数据库超级用户才能重新命名用户帐户。 当前会话用户不能重命名。(如果想这么干,先用另外一个用户账号连接。)


 第三和第四个变种修改用户会话的特定配置变量的缺省值。 当该用户随后启动一个新的会话时,声明的数值将成为会话的缺省,覆盖 任何出现在 postgresql.conf 里,或者从 postmaster  命令行接收到的设置。 普通用户可以修改它们自己的会话缺省。超级用户可以修改任何用户的缺省。  

PARAMETERS 参数

name

 想进行属性更改的用户名字。
password

 此帐号所使用的新口令。
ENCRYPTED
UNENCRYPTED

 这些关键字控制口令是否以加密形式存在 pg_shadow 里。 (参阅 CREATE USER [create_user(7)] 获取这个选项的更多信息。)
CREATEDB
NOCREATEDB

 这个子句定义该用户创建数据库的能力。 如果声明了CREATEDB,该用户可以创建她自己的数据库。 用NOCREATEDB将剥夺一个用户创建数据库的能力。
CREATEUSER
NOCREATEUSER

 这个子句决定一个用户能否创建新用户。 这个选项同样还令该用户成为超级用户,可以超越所有访问限制。
abstime

 该用户帐号口令的过期的日期(和可选的时间)。 要设置一个口令从不过期,可以用'infinity'。
newname

 用户的新名字。
parameter
value

 把该用户特定的配置变量的会话缺省设置为给定的数值。 如果 value 为 DEFAULT  或者使用了等效的 RESET,那么删除用户相关的变量, 并且该用户将在新会话中继承缺省设置。使用 RESET ALL  清除所有设置。


 参阅 SET [set(7)] 和 Section 16.4 ``Run-time Configuration'' 获取有关可用变量和数值的更多信息。

NOTES 注意


 使用 CREATE USER [create_user(7)] 创建新用户和 DROP USER [drop_user(7)] 删除用户。

ALTER USER 无法改变一个用户的组的成员性。 用 ALTER GROUP [alter_group(7)] 实现这个目地。


 使用 ALTER DATABASE [alter_database(7)],我们还可能把一个会话缺省和某个数据库绑定起来,而不是和某个用户绑定。  

EXAMPLES 例子


 更改一用户口令:

ALTER USER davide WITH PASSWORD 'hu8jmn3';


 更改一用户有效期:

ALTER USER manuel VALID UNTIL 'Jan 31 2030';


 更改一用户有效期, 声明其权限应该在用比UTC早一小时的时区记时的 2005 年 5 月 4 日正午失效

ALTER USER chris VALID UNTIL 'May 4 12:00:00 2005 +1';


 令用户永远有效:

ALTER USER fred VALID UNTIL 'infinity';


 赋予一用户创建新用户和新数据库的权限:

ALTER USER miriam CREATEUSER CREATEDB;

COMPATIBILITY 兼容性

ALTER USER 语句是 PostgreSQL 扩展。SQL 标准将用户的定义交给实现完成。  

SEE ALSO 参见

CREATE USER [create_user(7)], DROP USER [drop_user(l)], SET [set(l)]

#p#

NAME

ALTER USER - change a database user account

SYNOPSIS

ALTER USER name [ [ WITH ] option [ ... ] ]

where option can be:

    [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' 
    | CREATEDB | NOCREATEDB
    | CREATEUSER | NOCREATEUSER 
    | VALID UNTIL 'abstime'

ALTER USER name RENAME TO newname

ALTER USER name SET parameter { TO | = } { value | DEFAULT }
ALTER USER name RESET parameter

DESCRIPTION

ALTER USER is used to change the attributes of a PostgreSQL user account. Attributes not mentioned in the command retain their previous settings.

The first variant of this command in the synopsis changes certain global user privileges and authentication settings. (See below for details.) Only a database superuser can change these privileges and the password expiration with this command. Ordinary users can only change their own password.

The second variant changes the name of the user. Only a database superuser can rename user accounts. The session user cannot be renamed. (Connect as a different user if you need to do that.)

The third and the fourth variant change a user's session default for a specified configuration variable. Whenever the user subsequently starts a new session, the specified value becomes the session default, overriding whatever setting is present in postgresql.conf or has been received from the postmaster command line. Ordinary users can change their own session defaults. Superusers can change anyone's session defaults.  

PARAMETERS

name
The name of the user whose attributes are to be altered.
password
The new password to be used for this account.
ENCRYPTED
UNENCRYPTED
These key words control whether the password is stored encrypted in pg_shadow. (See CREATE USER [create_user(7)] for more information about this choice.)
CREATEDB
NOCREATEDB
These clauses define a user's ability to create databases. If CREATEDB is specified, the user will be allowed to create his own databases. Using NOCREATEDB will deny a user the ability to create databases.
CREATEUSER
NOCREATEUSER
These clauses determine whether a user will be permitted to create new users himself. This option will also make the user a superuser who can override all access restrictions.
abstime
The date (and, optionally, the time) at which this user's password is to expire. To set the password never to expire, use 'infinity'.
newname
The new name of the user.
parameter
value
Set this user's session default for the specified configuration parameter to the given value. If value is DEFAULT or, equivalently, RESET is used, the user-specific variable setting is removed and the user will inherit the system-wide default setting in new sessions. Use RESET ALL to clear all settings.

See SET [set(7)] and the section called ``Run-time Configuration'' in the documentation for more information about allowed parameter names and values.

NOTES

Use CREATE USER [create_user(7)] to add new users, and DROP USER [drop_user(7)] to remove a user.

ALTER USER cannot change a user's group memberships. Use ALTER GROUP [alter_group(7)] to do that.

Using ALTER DATABASE [alter_database(7)], it is also possible to tie a session default to a specific database rather than a user.  

EXAMPLES

Change a user password:

ALTER USER davide WITH PASSWORD 'hu8jmn3';

Change a user's valid until date:

ALTER USER manuel VALID UNTIL 'Jan 31 2030';

Change a user's valid until date, specifying that his authorization should expire at midday on 4th May 2005 using the time zone which is one hour ahead of UTC:

ALTER USER chris VALID UNTIL 'May 4 12:00:00 2005 +1';

Make a user valid forever:

ALTER USER fred VALID UNTIL 'infinity';

Give a user the ability to create other users and new databases:

ALTER USER miriam CREATEUSER CREATEDB;

COMPATIBILITY

The ALTER USER statement is a PostgreSQL extension. The SQL standard leaves the definition of users to the implementation.  

SEE ALSO

CREATE USER [create_user(7)], DROP USER [drop_user(l)], SET [set(l)]

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

2011-08-24 09:02:10

ALTER AGGRE中文man

2011-08-24 13:43:09

CREATE USER中文man

2011-08-24 09:42:15

alter_seque中文man

2011-08-24 09:14:47

alter_conve中文man

2011-08-24 09:48:46

alter_trigg中文man

2011-08-24 09:26:14

alter_funct中文man

2011-08-24 09:22:30

alter_domai中文man

2011-08-24 09:45:14

alter_table中文man

2011-08-24 09:29:18

alter_group中文man

2011-08-24 09:32:13

alter_langu中文man

2011-08-24 09:39:10

alter_schem中文man

2011-08-24 09:18:45

alter_datab中文man

2011-08-24 09:36:00

alter_opera中文man

2011-08-24 14:59:50

drop_user中文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-11 15:03:21

ACCESS中文man

2011-08-16 10:59:16

pwconv中文man
点赞
收藏

51CTO技术栈公众号