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 clause | What it does |
|---|---|
| DECLARE and SET | DECLARE 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 IMMEDIATE | EXECUTE IMMEDIATE runs a SQL statement built as a string at run time, with values bound through USING and results stored with INTO. |
| EXPORT DATA | EXPORT 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 DATA | LOAD 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...IN | BigQuery scripts loop with LOOP ... |
More of the BigQuery reference
Date functionsDatetime functionsTimestamp functionsString functionsAggregate functionsWindow functionsArray functionsJSON functionsConversion functionsConditional expressionsMathematical functionsHash and utility functionsQuery syntaxDDL statementsDML statementsINFORMATION_SCHEMAError messagesBigQuery pricingPricing calculator
