How to rename a table in Google Bigquery ?
Update (2021): BigQuery now has a Rename table command.
ALTER TABLE MYDATASET.MYTABLE RENAME TO MYDATASET.MYTABLE_NEW;
BigQuery does not allow you to rename a table name or a column name. The only option is to 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 get charged 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 form 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
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