How to RENAME TABLE in BigQuery

Galaxy Glossary

How do you rename a table in BigQuery without losing data?

ALTER TABLE ... RENAME TO changes an existing table’s name without affecting its data, schema, or permissions.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Why rename a table instead of recreating it?

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.

What is the basic RENAME TABLE syntax?

Use ALTER TABLE `project.dataset.old_name` RENAME TO `project.dataset.new_name`;. The statement is atomic and instantaneous within the same dataset.

How do I rename an ecommerce table?

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.

Can I rename across datasets or projects?

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.

Does renaming affect views or scheduled queries?

Dependent views, scheduled queries, and notebooks break because object references do not auto-update. Use INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS to locate dependencies before renaming.

Best practice checklist 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.

Why How to RENAME TABLE in BigQuery is important

How to RENAME TABLE in BigQuery Example Usage


-- Standard SQL
-- Rename Products to InventoryProducts in the ecommerce dataset
ALTER TABLE `acme.ecommerce.Products`
RENAME TO `acme.ecommerce.InventoryProducts`;

How to RENAME TABLE in BigQuery Syntax


ALTER TABLE `project_id.dataset_id.old_table_name`
RENAME TO `project_id.dataset_id.new_table_name`;

-- Example
ALTER TABLE `acme.ecommerce.Orders`
RENAME TO `acme.ecommerce.CustomerOrders`;

Common Mistakes

Frequently Asked Questions (FAQs)

Is renaming billed as data processed?

No. It’s a metadata change only, so it costs nothing and is near-instantaneous.

Can I roll back a rename?

You can immediately run a second rename back to the original name if still available. There is no automatic undo.

Will row-level security or column-level access policies persist?

Yes. All security policies stay attached to the table after a rename.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.