# Getting Started with BigQuery: Creating Datasets, Tables, and Running Queries

> Learn to create BigQuery datasets, tables, and run SQL queries. This guide covers essential steps for getting started with Google's serverless data warehouse.

- Repository: [Google/skills](https://github.com/google/skills)
- Tags: getting-started
- Published: 2026-08-09

---

**BigQuery is a fully-managed, serverless data warehouse that separates compute and storage, allowing you to create datasets, define table schemas, and query petabytes of data in seconds using standard SQL.**

This guide walks through the essential first steps for working with BigQuery based on the official `google/skills` repository. You will learn how to enable the API, structure your data using datasets and tables, and execute queries using the `bq` command-line tool.

## Understanding BigQuery Architecture

BigQuery’s architecture consists of **columnar storage** optimized for analytical workloads and a **distributed analytics engine** capable of querying terabytes in seconds and petabytes in minutes. According to [`skills/cloud/bigquery-basics/references/core-concepts.md`](https://github.com/google/skills/blob/main/skills/cloud/bigquery-basics/references/core-concepts.md) (lines 20-27), this serverless design eliminates the need to provision or manage servers.

The resource hierarchy is straightforward: an organization or folder contains **projects**, which hold **datasets**, and each dataset contains **tables** or **views** ([`core-concepts.md`](https://github.com/google/skills/blob/main/core-concepts.md), lines 27-34). Because BigQuery is serverless, you interact with resources via the `bq` CLI, the Cloud Console, or client libraries rather than managing infrastructure ([`SKILL.md`](https://github.com/google/skills/blob/main/SKILL.md), lines 19-27).

## Enabling the BigQuery API

Before creating resources, you must activate the BigQuery service in your Google Cloud project. This is the first step in the workflow documented in [`SKILL.md`](https://github.com/google/skills/blob/main/SKILL.md) (lines 21-64).

```bash
gcloud services enable bigquery.googleapis.com --quiet

```

This command enables the BigQuery API without prompting for confirmation, allowing subsequent CLI commands to execute successfully.

## Creating BigQuery Datasets and Tables

### Creating a Dataset with the bq CLI

A **dataset** is a logical container for related tables. Create one by specifying a location and dataset ID. The following command creates a dataset named `my_dataset` in the `US` region:

```bash
bq mk --dataset --location=US my_dataset

```

This follows the pattern outlined in the BigQuery basics skill file, which emphasizes specifying geographic locations for data residency and query performance.

### Defining a Schema and Creating Tables

Tables require a **schema** that defines column names, data types, and modes. Create a JSON schema file first, then reference it when creating the table.

Create [`schema.json`](https://github.com/google/skills/blob/main/schema.json) with the following structure:

```json
[
  {"name": "name", "type": "STRING", "mode": "REQUIRED"},
  {"name": "post_abbr", "type": "STRING", "mode": "NULLABLE"}
]

```

Then create the table using the schema file:

```bash
bq mk --table my_dataset.mytable schema.json

```

This command creates a table named `mytable` within `my_dataset` using the schema definitions provided in the JSON file.

## Running Queries in BigQuery

BigQuery uses **standard SQL** by default (enabled with `--use_legacy_sql=false`). You can query public datasets or your own tables immediately after creation.

Execute a query against the public USA names dataset:

```bash
bq query --use_legacy_sql=false \
'SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013`
 WHERE state = "TX" LIMIT 10'

```

This query retrieves the first ten names from the Texas records in the public dataset, demonstrating how to reference tables using the backtick notation `` `project.dataset.table` ``.

## Client Libraries and Additional Interfaces

While the `bq` CLI provides direct control, BigQuery also supports **client libraries** for Python, Java, Node.js, and Go. The reference file [`client-library-usage.md`](https://github.com/google/skills/blob/main/client-library-usage.md) contains implementation examples for programmatic dataset management and query execution. For production environments, refer to [`iam-security.md`](https://github.com/google/skills/blob/main/iam-security.md) for recommended roles and [`iac-usage.md`](https://github.com/google/skills/blob/main/iac-usage.md) for Terraform provisioning examples.

## Summary

- BigQuery is a serverless data warehouse with columnar storage and automatic scaling, requiring no server management ([`core-concepts.md`](https://github.com/google/skills/blob/main/core-concepts.md), lines 15-24).
- The resource hierarchy flows from project → dataset → table, with datasets acting as logical containers for related data.
- Use `gcloud services enable bigquery.googleapis.com` to activate the API before creating resources.
- Create datasets with `bq mk --dataset` and tables with `bq mk --table` using JSON schema definitions.
- Execute standard SQL queries using `bq query --use_legacy_sql=false` against both public and private datasets.

## Frequently Asked Questions

### How do I choose between the bq CLI and client libraries for BigQuery?

The **bq CLI** is optimal for administrative tasks, quick schema inspections, and ad-hoc queries from terminal environments. **Client libraries** (Python, Java, Node.js, Go) are better suited for application integration, ETL pipelines, and automated workflows requiring error handling and retry logic, as documented in [`client-library-usage.md`](https://github.com/google/skills/blob/main/client-library-usage.md).

### What is the difference between standard SQL and legacy SQL in BigQuery?

**Standard SQL** (SQL:2011 compliant) is the default syntax and supports advanced features like arrays, structs, and window functions. **Legacy SQL** uses BigQuery's original non-standard syntax and requires the `--use_legacy_sql=true` flag. New projects should use standard SQL exclusively for better portability and feature support.

### Do I need to specify a location when creating BigQuery datasets?

Yes, you should specify a **location** (region or multi-region) using the `--location` flag when creating datasets. This determines where your data resides and where query processing occurs. Choose locations close to your data sources or users to minimize latency and egress costs, as noted in [`core-concepts.md`](https://github.com/google/skills/blob/main/core-concepts.md).

### How does BigQuery handle schema validation when creating tables?

BigQuery enforces **schema validation** during table creation and data ingestion. When you create a table with `bq mk --table`, the JSON schema file defines column names, data types (STRING, INTEGER, FLOAT, etc.), and modes (REQUIRED, NULLABLE, REPEATED). Data that does not conform to this schema will be rejected during load jobs or streaming inserts.