Skip to main content
The REASSIGN OWNED statement changes the of all database objects (i.e., tables, types, or schemas) in the current database that are currently owned by a specific or . The REASSIGN OWNED statement performs a schema change. For more information about how online schema changes work in CockroachDB, see .
To change the ownership of any single object (e.g., a table or a database), use the OWNER TO subcommand of the object’s .

Required privileges

  • To reassign ownership with REASSIGN OWNED, the user must be a member of the current owner’s role and a member of the target owner’s role.
  • Members of the can always use REASSIGN OWNED BY.

Syntax

reassign_owned_by syntax diagram

Parameters

ParameterDescription
role\_spec\_listThe source role, or a comma-separated list of source roles.
role\_specThe target role.

Example

Setup

To follow along, run to start a temporary, in-memory cluster with the sample dataset preloaded:

Change the owner of all tables in a database

Suppose that the current owner of the users, vehicles, and rides tables in the movr database is a role named cockroachlabs.
Now suppose you want to change the owner for all of the tables owned by cockroachlabs to a new role named movrlabs.

See also