ALTER TABLE RENAME TO statement in BigQuery
The ALTER TABLE … RENAME TO statement is used to rename an existing table in BigQuery.
Syntax
ALTER TABLE [IF EXISTS] table_name
RENAME TO new_table_name
Arguments
- IF EXISTS → If the table does not exist, the statement has no effect and no error is thrown.
- table_name → The current name of the table to be renamed (use full table path syntax).
- new_table_name → The new name of the table. Only the table name is allowed (not the full path), and it must not already exist.
Example: Rename a Table
SQL
-- Rename table bq_cli_table to bq_table ALTER TABLE IF EXISTS `ashishcoder.bq_cli_dataset.bq_cli_table` RENAME TO `bq_table`;
Note: The new table name must be unique within the same dataset, and only the table name should be provided—do not include the project or dataset in the RENAME TO clause.