ALTER TABLE
ALTER TABLE changes the definition of an existing table. CoordinatorDB supports adding, dropping and renaming columns, and renaming the table itself.
Supported operations
text
ALTER TABLE table ADD COLUMN column type [constraints]
ALTER TABLE table DROP COLUMN column
ALTER TABLE table RENAME COLUMN old_name TO new_name
ALTER TABLE table RENAME TO new_nameA change must remain valid for existing rows and dependent schema objects. Constraints, indexes, views or triggers can prevent a change that would leave them invalid.
Example
Adding a defaulted column
sql
CREATE TABLE accounts(id INTEGER PRIMARY KEY);
INSERT INTO accounts VALUES (1);
ALTER TABLE accounts ADD COLUMN status String DEFAULT 'new';sql
SELECT id, status
FROM accounts
FORMAT csv;text
1,"new"See column operations for the detailed syntax and renaming a table for the rename form. Changing a column's type with ALTER COLUMN TYPE or ClickHouse MODIFY COLUMN is not supported; create a new table and copy explicitly converted values instead.