ALTER TABLE

On this page Carat arrow pointing down
Warning:
CockroachDB v2.1 is no longer supported as of April 30, 2020. For more details, refer to the Release Support Policy.

The ALTER TABLE statement applies a schema change to a table.

Note:

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

Subcommands

For information on using ALTER TABLE, see the documents for its relevant subcommands.

Subcommand Description
ADD COLUMN Add columns to tables.
ADD CONSTRAINT Add constraints to columns.
ALTER COLUMN Change or drop a column's DEFAULT constraint or drop the NOT NULL constraint.
ALTER TYPE New in v2.1: Change a column's data type.
CONFIGURE ZONE New in v2.1: Configure replication zones for a table.
DROP COLUMN Remove columns from tables.
DROP CONSTRAINT Remove constraints from columns.
EXPERIMENTAL_AUDIT Enable per-table audit logs.
PARTITION BY Repartition or unpartition a table with partitions (Enterprise-only).
RENAME COLUMN Change the names of columns.
RENAME TABLE Change the names of tables.
SPLIT AT Force a key-value layer range split at the specified row in the table.
VALIDATE CONSTRAINT Check whether values in a column match a constraint on the column.

Viewing schema changes

Whenever you initiate a schema change, CockroachDB registers it as a job, which you can view with SHOW JOBS.


Yes No
On this page

Yes No