How to rename a table in Google Bigquery ?

Update (2021): BigQuery now has a Rename table command. 

ALTER TABLE MYDATASET.MYTABLE RENAME TO MYTABLE_NEW;

------

Alternatively, to rename a table, you can also take a copy of the table and specify the new table name in BigQuery, though. This doesn't incur any additional charges other than the additional cost of storage. Once copied, you can delete the original table so you only pay for the storage once.

How to rename a BigQuery table using SQL:

First create a new table with the new name and then drop the old table:

CREATE OR REPLACE TABLE MYDATASET.MYTABLE_NEW AS 
SELECT * FROM MYDATASET.MYTABLE; DROP TABLE MYDATASET.MYTABLE;

How to copy a BigQuery table from WebUI:

From the BigQuery UI, select the table you wish to copy, then push the Copy Table button. Enter the desired new table name

How to copy a BigQuery table form Command line:

If you are a command line geek, you can use the below command to take a copy of a table:

bq cp mydataset.mytable mydataset2.mytable2

Once copied, remember to drop the old table, so you don't end up paying twice for storage

nVector

posted on 20 May 20

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds