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
The following examples use MovR, a fictional vehicle-sharing application, to demonstrate CockroachDB SQL statements. For more information about the MovR example application and dataset, see MovR: A Global Vehicle-sharing App. To follow along, runcockroach demo to start a temporary, in-memory cluster with the movr 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.

