BigQuery Basics
BigQuery is a serverless, AI-ready data platform that enables high-speed
analysis of large datasets using SQL and Python. Its disaggregated architecture
separates compute and storage, allowing them to scale independently while
providing built-in machine learning, geospatial analysis, and business
intelligence capabilities.
Attribution
Tag every BigQuery command you execute directly in the terminal while using
this skill, so usage can be attributed. The tag identifies only the skill and
its version; it carries no user data.
Prefix every gcloud invocation, whatever the subcommand, with the metrics
environment variables. Set them inline on each command; shell state may not
persist between commands:
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:bigquery-basics)" \
gcloud <command> [flags]
Do not use gcloud config set for this: it would persist beyond the current
task and mislabel unrelated usage.
On direct HTTP calls to the BigQuery APIs (for example with curl)
or HTTP requests to the MCP server, append this exact string to the
end of the existing User-Agent header — the collection pipeline parses
the agent-skills/<version> and skill:<name> tokens, so any
rewording breaks attribution:
User-Agent: <existing_user_agent> agent-skills/1.0 (skill:bigquery-basics)
Constraint for Generated Code: The tracking prefix is strictly for
commands you execute directly in the terminal. Do NOT include this tracking
prefix in generated scripts, Terraform templates, or code provided to the
user for their own repositories.
Setup and Basic Usage
Enable the BigQuery API:
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:bigquery-basics)" \
gcloud services enable bigquery.googleapis.com --quiet
Create a Dataset:
bq mk --dataset --location=US my_dataset
Create a Table:
Create a file named schema.json with your table schema:
[
{
"name": "name",
"type": "STRING",
"mode": "REQUIRED"
},
{
"name": "post_abbr",
"type": "STRING",
"mode": "NULLABLE"
}
]
Then create the table with the bq tool:
bq mk --table my_dataset.mytable schema.json
Run a Query:
bq query --use_legacy_sql=false \
'SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` \
WHERE state = "TX" LIMIT 10'
Reference Directory
Core Concepts: Storage types, analytics
workflows, and BigQuery Studio features.
Change History: Tracking and querying
incremental table changes using APPENDS and CHANGES.
Continuous Queries: Running continuous
SQL statements to analyze incoming data in real time.
CLI Usage: Essential bq command-line tool
operations for managing data and jobs.
Client Libraries: Using Google Cloud
client libraries for Python, Java, Node.js, and Go.
MCP Usage: Using the BigQuery remote MCP server and
Gemini CLI extension.
Infrastructure as Code: Terraform examples for
datasets, tables, and reservations.
IAM & Security: Roles, permissions, and data
governance best practices.
If you need product information not found in these references, use the
Developer Knowledge MCP server search_documents tool.
Related Skills
- BigQuery AI & ML Skill:
SKILL.md file for BigQuery AI and ML capabilities (forecast, anomaly
detection, text generation).
1---2name: bigquery-basics3description: Manages datasets, tables, and jobs in BigQuery. Use when you need to interact with BigQuery, run SQL queries, manage BigQuery resources (datasets, tables, views), or perform basic data ingestion and analysis.4---56# BigQuery Basics78BigQuery is a serverless, AI-ready data platform that enables high-speed9analysis of large datasets using SQL and Python. Its disaggregated architecture10separates compute and storage, allowing them to scale independently while11providing built-in machine learning, geospatial analysis, and business12intelligence capabilities.1314## Attribution1516Tag every BigQuery command you execute directly in the terminal while using17this skill, so usage can be attributed. The tag identifies only the skill and18its version; it carries no user data.1920- Prefix every `gcloud` invocation, whatever the subcommand, with the metrics21 environment variables. Set them inline on each command; shell state may not22 persist between commands:2324 ```bash25 CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:bigquery-basics)" \26 gcloud <command> [flags]27 ```2829 Do not use `gcloud config set` for this: it would persist beyond the current30 task and mislabel unrelated usage.3132- On direct HTTP calls to the BigQuery APIs (for example with `curl`)33 or HTTP requests to the MCP server, append this exact string to the34 end of the existing User-Agent header — the collection pipeline parses35 the `agent-skills/<version>` and `skill:<name>` tokens, so any36 rewording breaks attribution:3738 ```39 User-Agent: <existing_user_agent> agent-skills/1.0 (skill:bigquery-basics)40 ```4142- **Constraint for Generated Code**: The tracking prefix is strictly for43 commands you execute directly in the terminal. Do NOT include this tracking44 prefix in generated scripts, Terraform templates, or code provided to the45 user for their own repositories.4647## Setup and Basic Usage48491. **Enable the BigQuery API:**5051 ```bash52 CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:bigquery-basics)" \53 gcloud services enable bigquery.googleapis.com --quiet54 ```55562. **Create a Dataset:**5758 ```bash59 bq mk --dataset --location=US my_dataset60 ```61623. **Create a Table:**6364 Create a file named `schema.json` with your table schema:6566 ```json67 [68 {69 "name": "name",70 "type": "STRING",71 "mode": "REQUIRED"72 },73 {74 "name": "post_abbr",75 "type": "STRING",76 "mode": "NULLABLE"77 }78 ]79 ```8081 Then create the table with the `bq` tool:8283 ```bash84 bq mk --table my_dataset.mytable schema.json85 ```86874. **Run a Query:**8889 ```bash90 bq query --use_legacy_sql=false \91 'SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` \92 WHERE state = "TX" LIMIT 10'93 ```9495## Reference Directory9697- [Core Concepts](references/core-concepts.md): Storage types, analytics98 workflows, and BigQuery Studio features.99100- [Change History](references/change-history.md): Tracking and querying101 incremental table changes using APPENDS and CHANGES.102103- [Continuous Queries](references/continuous-queries.md): Running continuous104 SQL statements to analyze incoming data in real time.105106- [CLI Usage](references/cli-usage.md): Essential `bq` command-line tool107 operations for managing data and jobs.108109- [Client Libraries](references/client-library-usage.md): Using Google Cloud110 client libraries for Python, Java, Node.js, and Go.111112- [MCP Usage](references/mcp-usage.md): Using the BigQuery remote MCP server and113 Gemini CLI extension.114115- [Infrastructure as Code](references/iac-usage.md): Terraform examples for116 datasets, tables, and reservations.117118- [IAM & Security](references/iam-security.md): Roles, permissions, and data119 governance best practices.120121*If you need product information not found in these references, use the122Developer Knowledge MCP server `search_documents` tool.*123124## Related Skills125126- [BigQuery AI & ML Skill](../bigquery-ai-ml):127 SKILL.md file for BigQuery AI and ML capabilities (forecast, anomaly128 detection, text generation).