bq Command Examples

A Python-based tool for BigQuery, Google Cloud's fully managed and completely serverless enterprise data warehouse. More information: https://cloud.google.com/bigquery/docs/reference/bq-cli-reference.

bq query --nouse_legacy_sql 'SELECT COUNT(*) FROM {{DATASET_NAME}}.{{TABLE_NAME}}'

bq query --use_legacy_sql=false --parameter='ts_value:TIMESTAMP:2016-12-07 08:00:00' 'SELECT TIMESTAMP_ADD(@ts_value, INTERVAL 1 HOUR)'

bq mk --location=US {{dataset_name}}.{{table_name}}

bq ls --filter labels.{{key}}:{{value}} --max_results {{integer}} --format=prettyjson --project_id {{project_id}}

bq load --location {{location}} --source_format {{CSV|JSON|PARQUET|AVRO}} {{dataset}}.{{table}} {{path_to_source}}

bq cp {{dataset}}.{{OLD_TABLE}} {{dataset}}.{{new_table}}

bq help