- NAME
-
- gcloud alpha bq query - execute a BigQuery SQL query
- SYNOPSIS
-
-
gcloud alpha bq query[SQL_QUERY] [--async] [--endpoint-mode=ENDPOINT_MODE] [--job-creation-mode=JOB_CREATION_MODE] [--job-id=JOB_ID] [--location=LOCATION] [--[no-]use-cache] [--[no-]use-legacy-sql] [GCLOUD_WIDE_FLAG …]
-
- DESCRIPTION
-
(ALPHA)gcloud alpha bq queryexecutes a SQL query on Google Cloud BigQuery.The query can be passed as a positional argument or read from standard input (stdin).
- EXAMPLES
-
To execute a simple query:
gcloud alpha bq query 'SELECT 1'To execute a query passed through stdin:
echo 'SELECT 1' | gcloud alpha bq queryTo run a query asynchronously with a custom job ID:
gcloud alpha bq query 'SELECT 1' --async --job-id=my-job-id - POSITIONAL ARGUMENTS
-
- [
SQL_QUERY] - SQL query to execute. If not specified, query will be read from stdin.
- [
- FLAGS
-
--async- Return immediately, without waiting for the operation in progress to complete.
--endpoint-mode=ENDPOINT_MODE-
Specifies endpoint mode for a given command. Regional endpoints provide enhanced
data residency and reliability by ensuring your request is handled entirely
within the specified Google Cloud region. This differs from global endpoints,
which may process parts of the request outside the target region. Overrides the
default
regional/endpoint_modeproperty value for this command invocation.ENDPOINT_MODEmust be one of:global- (Default) Use global rather than regional endpoints.
regional- Only use regional endpoints. An error will be raised if a regional endpoint is not available for a given command.
regional-preferred- Use regional endpoints when available, otherwise use global endpoints. Recommended for most users.
--job-creation-mode=JOB_CREATION_MODE-
Specifies whether a job should be created.
JOB_CREATION_MODEmust be one of:JOB_CREATION_REQUIRED,JOB_CREATION_OPTIONAL. --job-id=JOB_ID-
A unique job ID to use for the query job. Forces a job to be created and is
incompatible with
--job-creation-mode=JOB_CREATION_OPTIONAL. --location=LOCATION- The geographic location where the query should run.
--[no-]use-cache-
Whether to look for the result in the query cache. Use
--use-cacheto enable and--no-use-cacheto disable. --[no-]use-legacy-sql-
Whether to use BigQuery's legacy SQL dialect for this query. Use
--use-legacy-sqlto enable and--no-use-legacy-sqlto disable.
- GCLOUD WIDE FLAGS
-
These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$ gcloud helpfor details. - REGIONAL ENDPOINTS
-
This command supports regional endpoints. To use regional endpoints for this
command, use the
--endpoint-mode=regional-preferredflag. To use regional endpoints by default, run$ gcloud config set regional/endpoint_mode regional-preferred. - NOTES
- This command is currently in alpha and might change without notice. If this command fails with API permission errors despite specifying the correct project, you might be trying to access an API with an invitation-only early access allowlist.
gcloud alpha bq query
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-09-29 UTC.