ALTER TABLE ... RENAME TO changes an existing table’s name without affecting its data, schema, or permissions.
Renaming preserves data, schema, ACLs, partitions, and streaming buffers, eliminating downtime and costly data copies. It is ideal during refactors, standardizing naming conventions, or merging datasets.
Use ALTER TABLE `project.dataset.old_name` RENAME TO `project.dataset.new_name`;
. The statement is atomic and instantaneous within the same dataset.
To transition Orders
to CustomerOrders
for clarity, run ALTER TABLE `shop.sales.Orders` RENAME TO `shop.sales.CustomerOrders`;
. Queries using the old name fail until updated.
No. BigQuery only supports renaming within the same dataset. For cross-dataset moves, create a new table with CREATE TABLE new AS SELECT * FROM old
, then drop the original.
Dependent views, scheduled queries, and notebooks break because object references do not auto-update. Use INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
to locate dependencies before renaming.
1) List dependencies via INFORMATION_SCHEMA
.
2) Communicate the change to your team.
3) Update application code, views, and BI tools.
4) Stage the change in a dev project first.
5) Keep the old name as an empty view alias if you need backward compatibility.
No. It’s a metadata change only, so it costs nothing and is near-instantaneous.
You can immediately run a second rename back to the original name if still available. There is no automatic undo.
Yes. All security policies stay attached to the table after a rename.