Search code examples
sqlgoogle-bigquery

Altering a table schema in Google Bigquery


How am I supposed to alter a table's column type in BigQuery using a standard ALTER command?

alter table mytable 
alter column timestamp set data type date

The message I get is this:

ALTER TABLE ALTER COLUMN SET DATA TYPE is not supported at [2:1]

I have also tried standard SQL command (which doesn't work). The documentation here:

https://cloud.google.com/bigquery/docs/managing-table-schemas

Doesn't mention anything about altering a column's type.


Solution

  • As of August 3, 2021, Google BigQuery supports the exact syntax from the original question. See:

    https://cloud.google.com/bigquery/docs/release-notes#August_03_2021

    As an example:

    ALTER TABLE [IF EXISTS] table_name
    ALTER COLUMN [IF EXISTS] column_name SET DATA TYPE data_type
    

    More details are available at:

    https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#alter_column_set_data_type_statement