{"Entry":{"collection":"sql","key":"drop-user-mapping","name":"DROP USER MAPPING","aliases":["dropusermapping"],"metadata":{"aliases":["dropusermapping"],"changed_in":["9.0","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":["DROP USER MAPPING [ IF EXISTS ] FOR { user_name | USER | CURRENT_USER | PUBLIC } SERVER server_name"],"removed":["DROP USER MAPPING [ IF EXISTS ] FOR { username | USER | CURRENT_USER | PUBLIC } SERVER servername"]},"to":"9.0"},{"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":["DROP USER MAPPING [ IF EXISTS ] FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC } SERVER server_name"],"removed":[]},"to":"14"}],"content_hash":"f09a69436e584dca0c6e311ef7dd66182287789eb81bae1cbd922f1b8903d74e","editorial":{},"first_version":"8.4","group":"foreign","imported_at":"2026-09-30T17:43:38.870613+08:00","last_version":"20","name":"DROP USER MAPPING","object":"USER MAPPING","position":9012,"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":"remove a user mapping for a foreign server","purpose_zh":"","related":["create-user-mapping","alter-user-mapping"],"slug":"drop-user-mapping","source_rev":"a709ab85","synopsis":"DROP USER MAPPING [ IF EXISTS ] FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC } SERVER server_name","verb":"DROP"}},"Definition":{"Collection":"sql","Key":"drop-user-mapping","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"drop-user-mapping","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-DROPUSERMAPPING","file":"sql-dropusermapping.html","lang":"en","name":"DROP USER MAPPING","purpose":"remove a user mapping for a foreign server","purpose_zh":"","related":["create-user-mapping","alter-user-mapping"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP USER MAPPING\u003c/code\u003e removes an existing user mapping from foreign server.\u003c/p\u003e\u003cp\u003eThe owner of a foreign server can drop user mappings for that server for any user. Also, a user can drop 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\u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDo not throw an error if the user mapping does not exist. A notice is issued in this case.\u003c/p\u003e\u003c/dd\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\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eDrop a user mapping \u003ccode class=\"literal\"\u003ebob\u003c/code\u003e, server \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e if it exists:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eDROP USER MAPPING IF EXISTS FOR bob SERVER foo;\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP USER MAPPING\u003c/code\u003e conforms to ISO/IEC 9075-9 (SQL/MED). The \u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e clause is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension.\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/alter-user-mapping/?v=18\" title=\"ALTER USER MAPPING\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER USER MAPPING\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"DROP USER MAPPING [ IF EXISTS ] FOR { \u003cem class=\"replaceable\"\u003e\u003ccode\u003euser_name\u003c/code\u003e\u003c/em\u003e | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC } SERVER \u003cem class=\"replaceable\"\u003e\u003ccode\u003eserver_name\u003c/code\u003e\u003c/em\u003e","synopsis_text":"DROP USER MAPPING [ IF EXISTS ] FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC } SERVER server_name"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"drop-user-mapping","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"DROP USER MAPPING","Summary":"删除外部服务器的用户映射","BodyHTML":"\u003cpre\u003eDROP USER MAPPING [ IF EXISTS ] FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC } SERVER server_name\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eDROP 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\u003ccode\u003eIF EXISTS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e如果该用户映射不存在，则不要报错。这种情况下会发出一个提示。\u003c/p\u003e\u003c/dd\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\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\u003eDROP USER MAPPING IF EXISTS FOR bob SERVER foo;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eDROP USER MAPPING\u003c/code\u003e符合 ISO/IEC 9075-9（SQL/MED）。\u003ccode\u003eIF EXISTS\u003c/code\u003e子句是\u003cspan\u003ePostgreSQL\u003c/span\u003e扩展。\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/alter-user-mapping/?v=18\" title=\"ALTER USER MAPPING\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER USER MAPPING\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"27676aabde6964fea066f68f4297bb1c2f3673564e9b9ee1896831be02f3d78f","Payload":{"purpose_zh":"删除外部服务器的用户映射","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP 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\u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e如果该用户映射不存在，则不要报错。这种情况下会发出一个提示。\u003c/p\u003e\u003c/dd\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\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\"\u003eDROP USER MAPPING IF EXISTS FOR bob SERVER foo;\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP USER MAPPING\u003c/code\u003e符合 ISO/IEC 9075-9（SQL/MED）。\u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e子句是\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e扩展。\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/alter-user-mapping/?v=18\" title=\"ALTER USER MAPPING\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER USER MAPPING\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"DROP USER MAPPING [ IF EXISTS ] FOR { \u003cem class=\"replaceable\"\u003e\u003ccode\u003euser_name\u003c/code\u003e\u003c/em\u003e | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC } SERVER \u003cem class=\"replaceable\"\u003e\u003ccode\u003eserver_name\u003c/code\u003e\u003c/em\u003e","synopsis_text":"DROP USER MAPPING [ IF EXISTS ] FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC } SERVER server_name"}},"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}
