Home » Bigquery » Tutorials » Alter table set options

BigQuery Alter table set options

Sets options on BigQuery table

Alter table set options example

    ALTER TABLE mydataset.mypartitionedtable
    SET OPTIONS (require_partition_filter=true)

Example 2: Set table expiration timestamp and description

    ALTER TABLE mydataset.mytable
    SET OPTIONS (
      expiration_timestamp=TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 7 DAY),
      description="Table that expires seven days from now"
    )

Example 3: Removing expiration timestamp

    ALTER TABLE mydataset.mytable
    SET OPTIONS (expiration_timestamp=NULL)

Explanation

table_set_options_list options

Option VALUE Explnation
default_kms_key_name STRING Specifies the default Cloud KMS key for encrypting table data in this dataset. You can override this value when you create a table.
default_partition_expiration_days FLOAT64 Specifies the default expiration time, in days, for table partitions in this dataset. You can override this value when you create a table.
default_table_expiration_days FLOAT64 Specifies the default expiration time, in days, for tables in this dataset. You can override this value when you create a table.
description STRING The description of the dataset.
friendly_name STRING A descriptive name for the dataset.
labels <ARRAY<STRUCT<STRING, STRING>>> An array of labels for the dataset, expressed as key-value pairs.
location STRING The location in which to create the dataset. If you don't specify this option, the dataset is created in the location where the query runs. If you specify this option and also explicitly set the location for the query job, the two values must match; otherwise the query fails.

Syntax reference

ALTER TABLE [IF EXISTS] [[project_name.]dataset_name.]table_name
SET OPTIONS(table_set_options_list)