ALTER DATABASE

The ALTER DATABASE statement applies a schema change to a database. For information on using ALTER DATABASE, see the pages for its relevant subcommands.

Note:

The ALTER DATABASE statement performs a schema change. For more information about how online schema changes work in CockroachDB, see Online Schema Changes.

Subcommands

Subcommand Description
CONFIGURE ZONE Configure replication zones for a database.
OWNER TO Change the owner of a database.
RENAME TO Change the name of a database.
ADD REGION Add a region to a multi-region database.
DROP REGION Drop a region from a multi-region database.
SET PRIMARY REGION Set the primary region of a multi-region database.
SET SECONDARY REGION Set the secondary region of a multi-region database for failover purposes.
DROP SECONDARY REGION Drop a secondary region from a multi-region database.
ADD SUPER REGION Add a super region made up of a set of database regions such that data from regional tables will be stored in only those regions.
DROP SUPER REGION Drop a super region made up of a set of database regions.
ALTER SUPER REGION Alter an existing super region to include a different set of regions. A super region is made up of a set of regions added with ADD REGION such that data from regional tables will be stored in only those regions.
ALTER LOCALITY New in v22.2: Persistently modify the configuration generated by the standard multi-region SQL abstractions on a per-region basis. For advanced users who want to customize their multi-region setup using Zone Config Extensions, a persistent, composable alternative to low-level zone configs.
SET {session variable} Set the default session variable values for the database. This syntax is identical to ALTER ROLE ALL IN DATABASE SET {session variable}.
RESET {session variable} Reset the default session variable values for the database to the system defaults. This syntax is identical to ALTER ROLE ALL IN DATABASE RESET {session variable}.
SURVIVE {ZONE,REGION} FAILURE Add a survival goal to a multi-region database.

Viewing schema changes

This schema change statement is registered as a job. You can view long-running jobs with SHOW JOBS.


Yes No