ALTER TABLE

On this page Carat arrow pointing down

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

Note:
To understand how CockroachDB changes schema elements without requiring table locking or other user-visible downtime, see Online Schema Changes in CockroachDB.

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.
DROP COLUMN Remove columns from tables.
DROP CONSTRAINT Remove constraints from columns.
EXPERIMENTAL_AUDIT Enable per-table audit logs.
PARTITION BY New in v2.0: 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