cockroachdb / cockroachdb/cockroach

Rename a table with backward compatibility

Open
#97,844 2 comments 0 reactions 0 assignees View on GitHub
C-enhancement O-community T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Is your feature request related to a problem? Please describe.**

Hello. In PostgreSQL I have a killer feature that I can rename a table with backward compatibility by creating a view which acts as a proxy table.

Step 1. Create a view
```
create view NEW_TABLE_NAME as (select * from OLD_TABLE);
```
Step 2. Migrate my service to use NEW_TABLE_NAME.
- This will work as in PostgreSQL you can use DML with views, and they will proxy all calls to the table.

Step 3. Rename a table and drop the view
```
begin;
rename view NEW_TABLE_NAME to TABLE_NAME_TO_DELETE;
rename table OLD_TABLE to NEW_TABLE_NAME;
drop view TABLE_NAME_TO_DELETE;
commit;
```

Is there any safe way to rename a table in cockroachDB as well?

Jira issue: CRDB-24916

Epic CRDB-28834

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.