Forrest logo
back to the bq tool

bq:tldr:ea5a3

bq: Run query against a BigQuery table using standard SQL, add `--dry_run` flag to estimate the number of bytes read by the query.
$ bq query --nouse_legacy_sql 'SELECT COUNT(*) FROM ${DATASET_NAME}.${TABLE_NAME}'
try on your machine

This command is used to execute a query in Google BigQuery using the bq command-line tool.

  • bq query: The command to run a query in BigQuery.
  • --nouse_legacy_sql: This flag is used to indicate that the query should use standard SQL instead of legacy SQL. Standard SQL is recommended as it offers more features and better compatibility with other SQL engines.
  • 'SELECT COUNT(*) FROM ${DATASET_NAME}.${TABLE_NAME}': The SQL query enclosed in single quotes. This specific query counts the total number of rows in a table specified by ${DATASET_NAME}.${TABLE_NAME}. ${DATASET_NAME} and ${TABLE_NAME} are placeholders that should be replaced with the actual dataset and table names. For example, if you want to count the number of rows in a table named 'orders' in a dataset named 'sales', you would replace ${DATASET_NAME}.${TABLE_NAME} with sales.orders.
This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the bq tool