alter_user 中文man頁面
NAME
ALTER USER - 改變數(shù)據(jù)庫用戶帳號
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 帳號的屬性。 沒有在該命令中出現(xiàn)的屬性保持原值。
這條命令模式中的***個變種修改某些全局用戶權(quán)限和認(rèn)證設(shè)置。 (見下文獲取細(xì)節(jié)。)只有數(shù)據(jù)庫超級用戶可以用這條命令改變這些權(quán)限和使口令失效。普通用戶只能修改它們自己的口令。
第二個變種改變用戶的名字。只有數(shù)據(jù)庫超級用戶才能重新命名用戶帳戶。 當(dāng)前會話用戶不能重命名。(如果想這么干,先用另外一個用戶賬號連接。)
第三和第四個變種修改用戶會話的特定配置變量的缺省值。 當(dāng)該用戶隨后啟動一個新的會話時,聲明的數(shù)值將成為會話的缺省,覆蓋 任何出現(xiàn)在 postgresql.conf 里,或者從 postmaster 命令行接收到的設(shè)置。 普通用戶可以修改它們自己的會話缺省。超級用戶可以修改任何用戶的缺省。
PARAMETERS 參數(shù)
- name
想進(jìn)行屬性更改的用戶名字。- password
此帳號所使用的新口令。- ENCRYPTED
- UNENCRYPTED
這些關(guān)鍵字控制口令是否以加密形式存在 pg_shadow 里。 (參閱 CREATE USER [create_user(7)] 獲取這個選項(xiàng)的更多信息。)- CREATEDB
- NOCREATEDB
這個子句定義該用戶創(chuàng)建數(shù)據(jù)庫的能力。 如果聲明了CREATEDB,該用戶可以創(chuàng)建她自己的數(shù)據(jù)庫。 用NOCREATEDB將剝奪一個用戶創(chuàng)建數(shù)據(jù)庫的能力。- CREATEUSER
- NOCREATEUSER
這個子句決定一個用戶能否創(chuàng)建新用戶。 這個選項(xiàng)同樣還令該用戶成為超級用戶,可以超越所有訪問限制。- abstime
該用戶帳號口令的過期的日期(和可選的時間)。 要設(shè)置一個口令從不過期,可以用'infinity'。- newname
用戶的新名字。- parameter
- value
把該用戶特定的配置變量的會話缺省設(shè)置為給定的數(shù)值。 如果 value 為 DEFAULT 或者使用了等效的 RESET,那么刪除用戶相關(guān)的變量, 并且該用戶將在新會話中繼承缺省設(shè)置。使用 RESET ALL 清除所有設(shè)置。
參閱 SET [set(7)] 和 Section 16.4 ``Run-time Configuration'' 獲取有關(guān)可用變量和數(shù)值的更多信息。
NOTES 注意
使用 CREATE USER [create_user(7)] 創(chuàng)建新用戶和 DROP USER [drop_user(7)] 刪除用戶。
ALTER USER 無法改變一個用戶的組的成員性。 用 ALTER GROUP [alter_group(7)] 實(shí)現(xiàn)這個目地。
使用 ALTER DATABASE [alter_database(7)],我們還可能把一個會話缺省和某個數(shù)據(jù)庫綁定起來,而不是和某個用戶綁定。
EXAMPLES 例子
更改一用戶口令:
ALTER USER davide WITH PASSWORD 'hu8jmn3';
更改一用戶有效期:
ALTER USER manuel VALID UNTIL 'Jan 31 2030';
更改一用戶有效期, 聲明其權(quán)限應(yīng)該在用比UTC早一小時的時區(qū)記時的 2005 年 5 月 4 日正午失效
ALTER USER chris VALID UNTIL 'May 4 12:00:00 2005 +1';
令用戶永遠(yuǎn)有效:
ALTER USER fred VALID UNTIL 'infinity';
賦予一用戶創(chuàng)建新用戶和新數(shù)據(jù)庫的權(quán)限:
ALTER USER miriam CREATEUSER CREATEDB;
COMPATIBILITY 兼容性
ALTER USER 語句是 PostgreSQL 擴(kuò)展。SQL 標(biāo)準(zhǔn)將用戶的定義交給實(shí)現(xiàn)完成。
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)]