Postgresql 中文操作指南

ALTER USER MAPPING

ALTER USER MAPPING — 更改用户映射的定义

ALTER USER MAPPING — change the definition of a user mapping

Synopsis

ALTER USER MAPPING FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | SESSION_USER | PUBLIC }
    SERVER server_name
    OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )

Description

ALTER USER MAPPING 更改用户映射的定义。

ALTER USER MAPPING changes the definition of a user mapping.

远程服务器的所有者可以更改该服务器的任何用户的用户映射。此外,如果已向用户授予 USAGE 权限,则用户可以更改其自己的用户名用户映射。

The owner of a foreign server can alter user mappings for that server for any user. Also, a user can alter a user mapping for their own user name if USAGE privilege on the server has been granted to the user.

Parameters

  • user_name

    • User name of the mapping. CURRENT_ROLE, CURRENT_USER, and USER match the name of the current user. PUBLIC is used to match all present and future user names in the system.

  • server_name

    • Server name of the user mapping.

  • OPTIONS ( [ ADD | SET | DROP ] _option ['value'] [, …​ ] )_

    • Change options for the user mapping. The new options override any previously specified options. ADD, SET, and DROP specify the action to be performed. ADD is assumed if no operation is explicitly specified. Option names must be unique; options are also validated by the server’s foreign-data wrapper.

Examples

更改用户映射 bob 、服务器 foo 的密码:

Change the password for user mapping bob, server foo:

ALTER USER MAPPING FOR bob SERVER foo OPTIONS (SET password 'public');

Compatibility

ALTER USER MAPPING 符合 ISO/IEC 9075-9 (SQL/MED)。有一个细微的语法问题:该标准省略 FOR 关键字。由于 CREATE USER MAPPINGDROP USER MAPPING 在类似位置使用 FOR ,而且 IBM DB2(作为另一个主要的 SQL/MED 实现)也要求将其用于 ALTER USER MAPPING ,因此 PostgreSQL 在此因一致性和互操作性考虑而背离该标准。

ALTER USER MAPPING conforms to ISO/IEC 9075-9 (SQL/MED). There is a subtle syntax issue: The standard omits the FOR key word. Since both CREATE USER MAPPING and DROP USER MAPPING use FOR in analogous positions, and IBM DB2 (being the other major SQL/MED implementation) also requires it for ALTER USER MAPPING, PostgreSQL diverges from the standard here in the interest of consistency and interoperability.