cockroachdb / cockroachdb/cockroach

sql/schema: ALTER TABLE RENAME with multiple table names

Open
#148,336 2 comments 0 reactions 0 assignees View on GitHub
A-schema-changes C-enhancement T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Under the legacy schema changer the following is possible

```sql
CREATE TABLE old_table1 (
id INT PRIMARY KEY,
name STRING
);

CREATE TABLE old_table2 (
id INT PRIMARY KEY,
description STRING
);

CREATE TABLE old_table3 (
id INT PRIMARY KEY,
created_at TIMESTAMPTZ
);

SET autocommit_before_ddl=off; -- 25.1

BEGIN;
ALTER TABLE old_table1 RENAME TO new_table1;
ALTER TABLE old_table2 RENAME TO new_table2;
ALTER TABLE old_table3 RENAME TO new_table3;
COMMIT;
```

It would be nice if we could provide a single line equivalent in declarative schema changer similar to how we can chain other ALTER:

```sql
ALTER TABLE old_table1 RENAME TO new_table1,
old_table2 RENAME TO new_table2,
old_table3 RENAME TO new_table3;
```

Jira issue: CRDB-51549

Epic CRDB-31472

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.