How to Rename a Table in BigQuery

BigQuery does not support the RENAME TABLE command, but you can effectively rename a table using a combination of copying and deleting the original table. This tutorial walks you through the process step by step.

Why BigQuery Doesn’t Support Direct Rename

Unlike some relational databases, BigQuery treats tables as immutable resources. This means you need to explicitly copy the table to a new name and optionally delete the old one.

Step 1: Copy the Table to the New Name

You can use either the SQL UI or the Google Cloud Console:

Option 1: Using SQL

CREATE TABLE `your-project.your_dataset.new_table_name`
AS SELECT * FROM `your-project.your_dataset.old_table_name`;

This creates a new table with the same data.

Option 2: Using Google Cloud Console

  1. Go to the BigQuery Console.
  2. Navigate to the table you want to rename.
  3. Click the three-dot menu and select Copy.
  4. Specify the new table name and click Copy.

Step 2: Verify the New Table

Make sure the new table has all the data and schema from the original table before proceeding. Run a simple query like:

SELECT COUNT(*) FROM `your-project.your_dataset.new_table_name`;

Step 3: Delete the Old Table (Optional)

Once you’ve verified the new table, you can safely delete the old one:

DROP TABLE `your-project.your_dataset.old_table_name`;

Or in the Console: click the three-dot menu next to the old table and select Delete.

Best Practices

  • Always back up critical data before making changes.
  • Use meaningful and consistent naming conventions.
  • Test on a small dataset before applying to production tables.

Summary

Renaming a table in BigQuery involves copying the table to a new name and deleting the old table. While it’s not a single command, following these steps ensures your data stays safe and your operations run smoothly.