{"Entry":{"collection":"sql","key":"reassign-owned","name":"REASSIGN OWNED","aliases":["reassign-owned"],"metadata":{"aliases":["reassign-owned"],"changed_in":["9.5","14"],"changes":[{"from":"8.1","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"8.2"},{"from":"8.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes","see_also"],"removed":[]},"status":"changed","synopsis":null,"to":"9.0"},{"from":"9.0","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","notes","compatibility"],"removed":[]},"status":"changed","synopsis":null,"to":"9.1"},{"from":"9.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","notes"],"removed":[]},"status":"changed","synopsis":null,"to":"9.3"},{"from":"9.3","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"9.4"},{"from":"9.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"changed","synopsis":{"added":["REASSIGN OWNED BY { old_role | CURRENT_USER | SESSION_USER } [, ...]","TO { new_role | CURRENT_USER | SESSION_USER }"],"removed":[]},"to":"9.5"},{"from":"9.5","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"9.6"},{"from":"10","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"11"},{"from":"13","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":{"added":["REASSIGN OWNED BY { old_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]","TO { new_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER }"],"removed":[]},"to":"14"},{"from":"16","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"17"},{"from":"18","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"19"}],"content_hash":"dab708c77c6a233e7574b625f8bccd311f4c7a929f66bd5d52cad51c73decaa4","editorial":{},"first_version":"8.2","group":"role","imported_at":"2026-09-30T17:43:38.104036+08:00","last_version":"20","name":"REASSIGN OWNED","object":"OWNED","position":5008,"present_in":["8.2","8.3","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 ownership of database objects owned by a database role","purpose_zh":"","related":["drop-owned","drop-role","alter-database"],"slug":"reassign-owned","source_rev":"a709ab85","synopsis":"REASSIGN OWNED BY { old_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]\nTO { new_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER }","verb":"REASSIGN"}},"Definition":{"Collection":"sql","Key":"reassign-owned","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"reassign-owned","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-REASSIGN-OWNED","file":"sql-reassign-owned.html","lang":"en","name":"REASSIGN OWNED","purpose":"change the ownership of database objects owned by a database role","purpose_zh":"","related":["drop-owned","drop-role","alter-database"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e instructs the system to change the ownership of database objects owned by any of the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_roles\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_role\u003c/code\u003e\u003c/em\u003e.\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\u003eold_role\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of a role. The ownership of all the objects within the current database, and of all shared objects (databases, tablespaces), owned by this role will be reassigned to \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_role\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_role\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of the role that will be made the new owner of the affected objects.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e is often used to prepare for the removal of one or more roles. Because \u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e does not affect objects within other databases, it is usually necessary to execute this command in each database that contains objects owned by a role that is to be removed.\u003c/p\u003e\u003cp\u003e\u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e requires membership on both the source role(s) and the target role.\u003c/p\u003e\u003cp\u003eThe \u003ca href=\"/docs/18/sql-drop-owned.html\" title=\"DROP OWNED\"\u003e\u003ccode class=\"command\"\u003eDROP OWNED\u003c/code\u003e\u003c/a\u003e command is an alternative that simply drops all the database objects owned by one or more roles.\u003c/p\u003e\u003cp\u003eThe \u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e command does not affect any privileges granted to the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_roles\u003c/code\u003e\u003c/em\u003e on objects that are not owned by them. Likewise, it does not affect default privileges created with \u003ccode class=\"command\"\u003eALTER DEFAULT PRIVILEGES\u003c/code\u003e. Use \u003ccode class=\"command\"\u003eDROP OWNED\u003c/code\u003e to revoke such privileges.\u003c/p\u003e\u003cp\u003eSee \u003ca href=\"/docs/18/role-removal.html\" title=\"21.4. Dropping Roles\"\u003eSection 21.4\u003c/a\u003e for more discussion.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eThe \u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e command 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/drop-owned/?v=18\" title=\"DROP OWNED\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP OWNED\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-role/?v=18\" title=\"DROP ROLE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP ROLE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-database/?v=18\" title=\"ALTER DATABASE\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER DATABASE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"REASSIGN OWNED BY { \u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_role\u003c/code\u003e\u003c/em\u003e | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]\n               TO { \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_role\u003c/code\u003e\u003c/em\u003e | CURRENT_ROLE | CURRENT_USER | SESSION_USER }","synopsis_text":"REASSIGN OWNED BY { old_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]\nTO { new_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER }"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"reassign-owned","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"REASSIGN OWNED","Summary":"更改一个数据库角色所拥有的数据库对象的所有权","BodyHTML":"\u003cpre\u003eREASSIGN OWNED BY { old_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]\nTO { new_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER }\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eREASSIGN OWNED\u003c/code\u003e指示系统将任何 \u003cem\u003e\u003ccode\u003eold_roles\u003c/code\u003e\u003c/em\u003e所拥有的数据库对象的所有权更改为 \u003cem\u003e\u003ccode\u003enew_role\u003c/code\u003e\u003c/em\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\u003eold_role\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e一个角色的名称。该角色在当前数据库中拥有的所有对象，以及该角色拥有的所有共享对象（数据库、表空间）的所有权，都将被重新分配给 \u003cem\u003e\u003ccode\u003enew_role\u003c/code\u003e\u003c/em\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003enew_role\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\u003eREASSIGN OWNED\u003c/code\u003e常用于为移除一个或多个角色做准备。由于\u003ccode\u003eREASSIGN OWNED\u003c/code\u003e不会影响其他数据库中的对象，因此通常需要在每个包含待移除角色所拥有对象的数据库中执行此命令。\u003c/p\u003e\u003cp\u003e执行 \u003ccode\u003eREASSIGN OWNED\u003c/code\u003e 要求你同时是源角色和目标角色的成员。\u003c/p\u003e\u003cp\u003e\u003ca href=\"/docs/18/sql-drop-owned.html\" title=\"DROP OWNED\" rel=\"nofollow\"\u003e\u003ccode\u003eDROP OWNED\u003c/code\u003e\u003c/a\u003e命令提供了另一种选择，它会直接删除一个或多个角色所拥有的全部数据库对象。\u003c/p\u003e\u003cp\u003e\u003ccode\u003eREASSIGN OWNED\u003c/code\u003e命令不会影响授予 \u003cem\u003e\u003ccode\u003eold_roles\u003c/code\u003e\u003c/em\u003e的、在非其所拥有的对象上的任何权限。同样，它也不会影响使用\u003ccode\u003eALTER DEFAULT PRIVILEGES\u003c/code\u003e创建的默认权限。如需撤销这类权限，请使用\u003ccode\u003eDROP OWNED\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e更多讨论请见\u003ca href=\"/docs/18/role-removal.html\" rel=\"nofollow\"\u003e第 21.4 节\u003c/a\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eREASSIGN OWNED\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/drop-owned/?v=18\" title=\"DROP OWNED\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP OWNED\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-role/?v=18\" title=\"DROP ROLE\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP ROLE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-database/?v=18\" title=\"ALTER DATABASE\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER DATABASE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"49382ecaf3045d423ce017abf058ac2ae44de626eafce8ddc4303cbc90aeda36","Payload":{"purpose_zh":"更改一个数据库角色所拥有的数据库对象的所有权","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e指示系统将任何 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_roles\u003c/code\u003e\u003c/em\u003e所拥有的数据库对象的所有权更改为 \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_role\u003c/code\u003e\u003c/em\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\u003eold_role\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e一个角色的名称。该角色在当前数据库中拥有的所有对象，以及该角色拥有的所有共享对象（数据库、表空间）的所有权，都将被重新分配给 \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_role\u003c/code\u003e\u003c/em\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_role\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=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e常用于为移除一个或多个角色做准备。由于\u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e不会影响其他数据库中的对象，因此通常需要在每个包含待移除角色所拥有对象的数据库中执行此命令。\u003c/p\u003e\u003cp\u003e执行 \u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e 要求你同时是源角色和目标角色的成员。\u003c/p\u003e\u003cp\u003e\u003ca href=\"/docs/18/sql-drop-owned.html\" title=\"DROP OWNED\"\u003e\u003ccode class=\"command\"\u003eDROP OWNED\u003c/code\u003e\u003c/a\u003e命令提供了另一种选择，它会直接删除一个或多个角色所拥有的全部数据库对象。\u003c/p\u003e\u003cp\u003e\u003ccode class=\"command\"\u003eREASSIGN OWNED\u003c/code\u003e命令不会影响授予 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_roles\u003c/code\u003e\u003c/em\u003e的、在非其所拥有的对象上的任何权限。同样，它也不会影响使用\u003ccode class=\"command\"\u003eALTER DEFAULT PRIVILEGES\u003c/code\u003e创建的默认权限。如需撤销这类权限，请使用\u003ccode class=\"command\"\u003eDROP OWNED\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e更多讨论请见\u003ca href=\"/docs/18/role-removal.html\" title=\"21.4. 删除角色\"\u003e第 21.4 节\u003c/a\u003e。\u003c/p\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eREASSIGN OWNED\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/drop-owned/?v=18\" title=\"DROP OWNED\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP OWNED\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-role/?v=18\" title=\"DROP ROLE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP ROLE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-database/?v=18\" title=\"ALTER DATABASE\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER DATABASE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"REASSIGN OWNED BY { \u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_role\u003c/code\u003e\u003c/em\u003e | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]\n               TO { \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_role\u003c/code\u003e\u003c/em\u003e | CURRENT_ROLE | CURRENT_USER | SESSION_USER }","synopsis_text":"REASSIGN OWNED BY { old_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]\nTO { new_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER }"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.2","8.3","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}
