Request a demo

BigQuery reference

BigQuery scripting and data movement

Multi-statement queries let you declare variables, loop, branch and build SQL at run time, and LOAD DATA and EXPORT DATA move data in and out of BigQuery from SQL.

Statements and clauses in this category

Statement or clauseWhat it does
DECLARE and SETDECLARE creates a variable in a BigQuery multi-statement query and SET assigns it: DECLARE run_date DATE DEFAULT CURRENT_DATE(); SET run_date = '2026-11-22'.
EXECUTE IMMEDIATEEXECUTE IMMEDIATE runs a SQL statement built as a string at run time, with values bound through USING and results stored with INTO.
EXPORT DATAEXPORT DATA writes the result of a query to files in Cloud Storage (CSV, JSON, Avro or Parquet), or to Bigtable, Spanner, Pub/Sub or AlloyDB.
LOAD DATALOAD DATA loads files from Cloud Storage (CSV, JSON, Avro, Parquet, ORC) into a BigQuery table from SQL: LOAD DATA INTO appends, LOAD DATA OVERWRITE replaces, and a missing table is created.
LOOP, WHILE and FOR...INBigQuery scripts loop with LOOP ...

More of the BigQuery reference

Observability for every BigQuery table, in about 15 minutes

Masthead detects freshness, volume and schema anomalies, monitors pipeline errors and maps column-level lineage across all your projects, from logs and metadata only.