Use the bq query command.
With this method, you will add the flags destination_table (or target_dataset), --schedule and --display_name options to your bq query command to create a scheduled query.
bq query \
--display_name=name \
--destination_table=table \
--schedule=interval
Where:
-
name is the display name for the scheduled query. The display name can be any value that allows you to easily identify the scheduled query if you need to modify it later.
-
table is the destination table for the query results.
-
--target_dataset is an alternative way to name the target dataset for the query results, when used with DDL/DML queries.
-
Use either --destination_table or --target_dataset, but not both.
-
interval, when used with bq query makes a query a recurring scheduled query. A schedule for how often the query should run is required. Examples:
Optional flags:
-
--project_id is your project ID. If --project_id isn't specified, the default project is used.
-
--replace will truncate the destination table and write new results with every run of the scheduled query.
-
--append_table will append results to the destination table.