REASSIGN OWNED statement changes the ownership of all database objects (i.e., tables, types, or schemas) in the current database that are currently owned by a specific role or user.
The
REASSIGN OWNED statement performs a schema change. For more information about how online schema changes work in CockroachDB, see Online Schema Changes.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
adminrole can always useREASSIGN OWNED BY.
Syntax
Parameters
Example
Setup
To follow along, runcockroach demo to start a temporary, in-memory cluster with the movr sample dataset preloaded:
Change the owner of all tables in a database
Suppose that the current owner of theusers, vehicles, and rides tables in the movr database is a role named cockroachlabs.
cockroachlabs to a new role named movrlabs.

