How to RENAME TABLE in Snowflake

Galaxy Glossary

How do I rename a table in Snowflake without losing data?

ALTER TABLE … RENAME TO changes a table’s name in Snowflake without touching its data, schema, or privileges.

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

What does RENAME TABLE do in Snowflake?

The command changes an existing table’s name instantly at the metadata level.Data, permissions, clustering keys, and Time Travel history stay intact.

Why would I rename a table?

Typical reasons include business-term updates (OrdersCustomerOrders), archiving (OrdersOrders_2023), or refactoring schemas during migrations.

How do I rename a table?

ALTER TABLE Orders RENAME TO CustomerOrders;

How do I avoid errors if the table might be missing?

ALTER TABLE IF EXISTS Orders RENAME TO CustomerOrders;

Can I rename and move the table to another schema?

ALTER TABLE sales.Orders RENAME TO archive.CustomerOrders_2023;

Will downstream objects break?

Views and grants automatically follow the new name, but raw SQL in apps or ETL jobs will not.Track and update hard-coded references.

Best practices for RENAME TABLE

• Qualify names with schema to avoid ambiguity.
• Use IF EXISTS in automated pipelines.
• Record the change in version control and notify teams.

Common mistakes to avoid

See details in the mistakes section below.

Can I undo a rename?

Yes—run another ALTER TABLE … RENAME TO returning the table to its original name, provided no new object now uses that name.

.

Why How to RENAME TABLE in Snowflake is important

How to RENAME TABLE in Snowflake Example Usage


-- Archive last year’s orders table and move it to the archive schema
ALTER TABLE IF EXISTS sales.Orders
RENAME TO archive.Orders_2023;

How to RENAME TABLE in Snowflake Syntax


-- Basic
ALTER TABLE <old_table_name>
RENAME TO <new_table_name>;

-- With IF EXISTS safeguard
ALTER TABLE IF EXISTS <old_table_name>
RENAME TO <new_table_name>;

-- Cross-schema rename (same database)
ALTER TABLE <old_schema>.<old_table_name>
RENAME TO <new_schema>.<new_table_name>;

-- Example in ecommerce context
ALTER TABLE Orders
RENAME TO CustomerOrders;

Common Mistakes

Frequently Asked Questions (FAQs)

Does RENAME TABLE lock the table?

No. The operation is metadata-only and completes almost instantly without blocking reads or writes.

Can I use variables in the table name?

Yes. In Snowflake Scripting, build dynamic SQL with the IDENTIFIER() function to insert variable values.

Will Time Travel still work after a rename?

Yes. Historical data remains accessible through the new table name because Time Travel follows the physical table, not its identifier.

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.