question

senorstew avatar image
senorstew asked

Alter Column in BigQuery

I'm ashamed to ask such a basic question but, here goes. I'm trying to change the datatype of a column in a saved table in Birquery. The SQL format I'm familiar with is "Alter Table TABLENAME Alter Column COLUMN NAME NEW COLUMN TYPE; (i.e., Alter Table Mytable Alter Column bike_id string"; Bigquery won't process this and tells me it's looking for either a "Drop", or "Set" keyword. What am I doing wrong. Thanks for the help.

sqlserver2012
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered

According to BigQuery documentation, that's not possible with a DDL statement:

All other schema modifications are unsupported and require manual workarounds, including:

  • Changing a column's name
  • Changing a column's data type
  • Changing a column's mode (aside from relaxing REQUIRED columns to NULLABLE)

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


They suggest some workarounds here: https://cloud.google.com/bigquery/docs/manually-changing-schemas

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.