{"Entry":{"collection":"sql","key":"alter-user-mapping","name":"ALTER USER MAPPING","aliases":["alterusermapping"],"metadata":{"aliases":["alterusermapping"],"changed_in":["9.0","9.5","14"],"changes":[{"from":"8.3","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"8.4"},{"from":"8.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":{"added":["ALTER USER MAPPING FOR { user_name | USER | CURRENT_USER | PUBLIC }","SERVER server_name"],"removed":["ALTER USER MAPPING FOR { username | USER | CURRENT_USER | PUBLIC }","SERVER servername"]},"to":"9.0"},{"from":"9.0","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["examples"],"removed":[]},"status":"changed","synopsis":null,"to":"9.1"},{"from":"9.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"changed","synopsis":{"added":["ALTER USER MAPPING FOR { user_name | USER | CURRENT_USER | SESSION_USER | PUBLIC }"],"removed":[]},"to":"9.5"},{"from":"9.5","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"9.6"},{"from":"13","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":{"added":["ALTER USER MAPPING FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | SESSION_USER | PUBLIC }"],"removed":[]},"to":"14"}],"content_hash":"508dc71f7d86f085177dff4c0d8c40b3ac10560cf0eb8097a54de36cd7a04d61","editorial":{},"first_version":"8.4","group":"foreign","imported_at":"2026-09-30T17:43:38.862974+08:00","last_version":"20","name":"ALTER USER MAPPING","object":"USER MAPPING","position":9011,"present_in":["8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"purpose":"change the definition of a user mapping","purpose_zh":"","related":["create-user-mapping","drop-user-mapping"],"slug":"alter-user-mapping","source_rev":"a709ab85","synopsis":"ALTER USER MAPPING FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | SESSION_USER | PUBLIC }\nSERVER server_name\nOPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )","verb":"ALTER"}},"Definition":{"Collection":"sql","Key":"alter-user-mapping","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"alter-user-mapping","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-ALTERUSERMAPPING","file":"sql-alterusermapping.html","lang":"en","name":"ALTER USER MAPPING","purpose":"change the definition of a user mapping","purpose_zh":"","related":["create-user-mapping","drop-user-mapping"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eALTER USER MAPPING\u003c/code\u003e changes the definition of a user mapping.\u003c/p\u003e\u003cp\u003eThe 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 \u003ccode class=\"literal\"\u003eUSAGE\u003c/code\u003e privilege on the server has been granted to the user.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003euser_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eUser name of the mapping. \u003ccode class=\"literal\"\u003eCURRENT_ROLE\u003c/code\u003e, \u003ccode class=\"literal\"\u003eCURRENT_USER\u003c/code\u003e, and \u003ccode class=\"literal\"\u003eUSER\u003c/code\u003e match the name of the current user. \u003ccode class=\"literal\"\u003ePUBLIC\u003c/code\u003e is used to match all present and future user names in the system.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eserver_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eServer name of the user mapping.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eOPTIONS ( [ ADD | SET | DROP ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e ['\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e'] [, ... ] )\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eChange options for the user mapping. The new options override any previously specified options. \u003ccode class=\"literal\"\u003eADD\u003c/code\u003e, \u003ccode class=\"literal\"\u003eSET\u003c/code\u003e, and \u003ccode class=\"literal\"\u003eDROP\u003c/code\u003e specify the action to be performed. \u003ccode class=\"literal\"\u003eADD\u003c/code\u003e is assumed if no operation is explicitly specified. Option names must be unique; options are also validated by the server's foreign-data wrapper.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eChange the password for user mapping \u003ccode class=\"literal\"\u003ebob\u003c/code\u003e, server \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eALTER USER MAPPING FOR bob SERVER foo OPTIONS (SET password 'public');\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eALTER USER MAPPING\u003c/code\u003e conforms to ISO/IEC 9075-9 (SQL/MED). There is a subtle syntax issue: The standard omits the \u003ccode class=\"literal\"\u003eFOR\u003c/code\u003e key word. Since both \u003ccode class=\"literal\"\u003eCREATE USER MAPPING\u003c/code\u003e and \u003ccode class=\"literal\"\u003eDROP USER MAPPING\u003c/code\u003e use \u003ccode class=\"literal\"\u003eFOR\u003c/code\u003e in analogous positions, and IBM DB2 (being the other major SQL/MED implementation) also requires it for \u003ccode class=\"literal\"\u003eALTER USER MAPPING\u003c/code\u003e, PostgreSQL diverges from the standard here in the interest of consistency and interoperability.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/create-user-mapping/?v=18\" title=\"CREATE USER MAPPING\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE USER MAPPING\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-user-mapping/?v=18\" title=\"DROP USER MAPPING\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP USER MAPPING\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"ALTER USER MAPPING FOR { \u003cem class=\"replaceable\"\u003e\u003ccode\u003euser_name\u003c/code\u003e\u003c/em\u003e | USER | CURRENT_ROLE | CURRENT_USER | SESSION_USER | PUBLIC }\n    SERVER \u003cem class=\"replaceable\"\u003e\u003ccode\u003eserver_name\u003c/code\u003e\u003c/em\u003e\n    OPTIONS ( [ ADD | SET | DROP ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e ['\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e'] [, ... ] )","synopsis_text":"ALTER USER MAPPING FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | SESSION_USER | PUBLIC }\nSERVER server_name\nOPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"alter-user-mapping","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"ALTER USER MAPPING","Summary":"更改用户映射的定义","BodyHTML":"\u003cpre\u003eALTER USER MAPPING FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | SESSION_USER | PUBLIC }\nSERVER server_name\nOPTIONS ( [ ADD | SET | DROP ] option [\u0026#39;value\u0026#39;] [, ... ] )\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eALTER USER MAPPING\u003c/code\u003e更改用户映射的定义。\u003c/p\u003e\u003cp\u003e外部服务器的拥有者可以修改任意用户到该服务器的用户映射。此外，如果某个用户已被授予该服务器上的\u003ccode\u003eUSAGE\u003c/code\u003e权限，那么该用户也可以修改其自己用户名对应的用户映射。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003euser_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该映射的用户名。\u003ccode\u003eCURRENT_ROLE\u003c/code\u003e、\u003ccode\u003eCURRENT_USER\u003c/code\u003e和\u003ccode\u003eUSER\u003c/code\u003e匹配当前用户的名称。\u003ccode\u003ePUBLIC\u003c/code\u003e用于匹配系统中当前及未来的所有用户名。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eserver_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该用户映射所属服务器的名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eOPTIONS ( [ ADD | SET | DROP ] \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [\u0026#39;\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u0026#39;] [, ... ] )\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e更改该用户映射的选项。新选项会覆盖先前指定的任何选项。\u003ccode\u003eADD\u003c/code\u003e、\u003ccode\u003eSET\u003c/code\u003e和\u003ccode\u003eDROP\u003c/code\u003e 指定要执行的动作。如果未显式指定操作，则假定为\u003ccode\u003eADD\u003c/code\u003e。选项名必须唯一；这些选项还会由该服务器的外部数据包装器进行验证。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e更改用户映射\u003ccode\u003ebob\u003c/code\u003e、服务器\u003ccode\u003efoo\u003c/code\u003e的密码：\u003c/p\u003e\u003cpre\u003eALTER USER MAPPING FOR bob SERVER foo OPTIONS (SET password \u0026#39;public\u0026#39;);\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eALTER USER MAPPING\u003c/code\u003e符合 ISO/IEC 9075-9 (SQL/MED)。这里有一个细微的语法问题：该标准省略了\u003ccode\u003eFOR\u003c/code\u003e 关键字。由于\u003ccode\u003eCREATE USER MAPPING\u003c/code\u003e和 \u003ccode\u003eDROP USER MAPPING\u003c/code\u003e都在类似位置使用 \u003ccode\u003eFOR\u003c/code\u003e，而 IBM DB2（另一个主要的 SQL/MED 实现）也要求在 \u003ccode\u003eALTER USER MAPPING\u003c/code\u003e中使用它，因此为了保持一致性和互操作性，PostgreSQL 在这里偏离了标准。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/create-user-mapping/?v=18\" title=\"CREATE USER MAPPING\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE USER MAPPING\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-user-mapping/?v=18\" title=\"DROP USER MAPPING\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP USER MAPPING\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"1c6cb4d06bb425b42a5d8532564fb6710cc44e5a7b2fe1f8c2b9468dfe50f743","Payload":{"purpose_zh":"更改用户映射的定义","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eALTER USER MAPPING\u003c/code\u003e更改用户映射的定义。\u003c/p\u003e\u003cp\u003e外部服务器的拥有者可以修改任意用户到该服务器的用户映射。此外，如果某个用户已被授予该服务器上的\u003ccode class=\"literal\"\u003eUSAGE\u003c/code\u003e权限，那么该用户也可以修改其自己用户名对应的用户映射。\u003c/p\u003e","key":"description","title":"描述"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003euser_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该映射的用户名。\u003ccode class=\"literal\"\u003eCURRENT_ROLE\u003c/code\u003e、\u003ccode class=\"literal\"\u003eCURRENT_USER\u003c/code\u003e和\u003ccode class=\"literal\"\u003eUSER\u003c/code\u003e匹配当前用户的名称。\u003ccode class=\"literal\"\u003ePUBLIC\u003c/code\u003e用于匹配系统中当前及未来的所有用户名。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eserver_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该用户映射所属服务器的名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eOPTIONS ( [ ADD | SET | DROP ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e ['\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e'] [, ... ] )\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e更改该用户映射的选项。新选项会覆盖先前指定的任何选项。\u003ccode class=\"literal\"\u003eADD\u003c/code\u003e、\u003ccode class=\"literal\"\u003eSET\u003c/code\u003e和\u003ccode class=\"literal\"\u003eDROP\u003c/code\u003e 指定要执行的动作。如果未显式指定操作，则假定为\u003ccode class=\"literal\"\u003eADD\u003c/code\u003e。选项名必须唯一；这些选项还会由该服务器的外部数据包装器进行验证。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"参数"},{"html":"\u003cp\u003e更改用户映射\u003ccode class=\"literal\"\u003ebob\u003c/code\u003e、服务器\u003ccode class=\"literal\"\u003efoo\u003c/code\u003e的密码：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eALTER USER MAPPING FOR bob SERVER foo OPTIONS (SET password 'public');\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eALTER USER MAPPING\u003c/code\u003e符合 ISO/IEC 9075-9 (SQL/MED)。这里有一个细微的语法问题：该标准省略了\u003ccode class=\"literal\"\u003eFOR\u003c/code\u003e 关键字。由于\u003ccode class=\"literal\"\u003eCREATE USER MAPPING\u003c/code\u003e和 \u003ccode class=\"literal\"\u003eDROP USER MAPPING\u003c/code\u003e都在类似位置使用 \u003ccode class=\"literal\"\u003eFOR\u003c/code\u003e，而 IBM DB2（另一个主要的 SQL/MED 实现）也要求在 \u003ccode class=\"literal\"\u003eALTER USER MAPPING\u003c/code\u003e中使用它，因此为了保持一致性和互操作性，PostgreSQL 在这里偏离了标准。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/create-user-mapping/?v=18\" title=\"CREATE USER MAPPING\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE USER MAPPING\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-user-mapping/?v=18\" title=\"DROP USER MAPPING\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP USER MAPPING\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"ALTER USER MAPPING FOR { \u003cem class=\"replaceable\"\u003e\u003ccode\u003euser_name\u003c/code\u003e\u003c/em\u003e | USER | CURRENT_ROLE | CURRENT_USER | SESSION_USER | PUBLIC }\n    SERVER \u003cem class=\"replaceable\"\u003e\u003ccode\u003eserver_name\u003c/code\u003e\u003c/em\u003e\n    OPTIONS ( [ ADD | SET | DROP ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e ['\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e'] [, ... ] )","synopsis_text":"ALTER USER MAPPING FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | SESSION_USER | PUBLIC }\nSERVER server_name\nOPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
