Skip to content

Rename a table ​

Rename a table with ALTER TABLE ... RENAME TO. Its stored rows remain available under the new name.

Syntax ​

text
ALTER TABLE old_name RENAME TO new_name

The ClickHouse RENAME TABLE command is not supported. Use RENAME COLUMN to change a column name instead.

Example ​

Renaming an events table ​

sql
CREATE TABLE old_events(id INTEGER, kind String);
INSERT INTO old_events VALUES (1, 'view');
ALTER TABLE old_events RENAME TO new_events;
sql
SELECT id, kind
FROM new_events
FORMAT csv;
text
1,"view"

Later statements must use new_events. A conflicting destination name or an incompatible schema dependency can prevent the rename.