# BigQuery INSERT: Syntax and Examples | Masthead

INSERT adds rows to a BigQuery table from a VALUES list or a SELECT query. On-demand it bills only the bytes the SELECT reads. Insert in batches: BigQuery is not built for row-by-row INSERTs, and after 1,500 INSERT statements on a table in a day, extra ones are queued.

> For the index of this section of the site, see [llms.txt](https://mastheadata.com/llms.txt)

BigQuery · DML statement

# BigQuery INSERT

INSERT adds rows to a BigQuery table from a VALUES list or a SELECT query. On-demand it bills only the bytes the SELECT reads. Insert in batches: BigQuery is not built for row-by-row INSERTs, and after 1,500 INSERT statements on a table in a day, extra ones are queued.

GoogleSQL for BigQuery · Checked against the [official reference](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#insert_statement) in November 2026

`INSERT [INTO] table (columns) VALUES (...), (...)` adds literal rows, and `INSERT INTO table (columns) SELECT ...` adds the result of a query; a WITH clause goes after the column list. The column list is optional except for ingestion-time partitioned tables. Without it, values are matched to all columns in schema order, which breaks silently as soon as someone adds a column in the middle of a SELECT. Columns you leave out get their default value, a generated identity value, or NULL; the `DEFAULT` keyword requests the default explicitly. Values must have the column's type or one that coerces to it.

Each INSERT is an implicit transaction: all rows are added or none. INSERT never conflicts with other DML statements running on the same table, unlike UPDATE, DELETE and MERGE. For ingestion-time partitioned tables you choose the partition by inserting into the `_PARTITIONTIME` pseudocolumn, as in `INSERT INTO t (_PARTITIONTIME, a, b) SELECT TIMESTAMP('2026-11-22'), ...`; only exact partition boundaries are allowed. For time-unit column partitioned tables, rows land in the partition of their partitioning column value.

BigQuery is an analytics warehouse, not an OLTP database. Each INSERT is a job with seconds of overhead, and the first 1,500 INSERT statements per table in a 24-hour period run immediately; after that, only 10 run concurrently per table, up to 100 wait in a queue, and up to 25 DML statements per table are accepted every 10 seconds. Collect rows and insert them in one statement, load files with [LOAD DATA](https://mastheadata.com/bigquery/sql/load-data.md), or stream with the Storage Write API. There is no `INSERT ... ON CONFLICT` and primary keys are not enforced: use [MERGE](https://mastheadata.com/bigquery/sql/merge.md) for upserts.

## Syntax

```
INSERT [INTO] table_name [(column[, ...])]
VALUES (expression | DEFAULT[, ...])[, (...)]

INSERT [INTO] table_name [(column[, ...])]
[WITH ...]
SELECT ...
```

## Arguments and return value

| Argument | Description |
| --- | --- |
| `table_name` | Target table. Not a view, materialized view or wildcard table. |
| `column list` | Columns to fill, in the order of the values. Required for ingestion-time partitioned tables; recommended everywhere. |
| `VALUES / SELECT` | Literal rows, or a query whose columns match the column list by position. |
| `DEFAULT` | Uses the column's default value or generated identity value; NULL if it has none. |

**Returns:** No result set. Job statistics report `inserted_row_count` (`dml_statistics` in INFORMATION\_SCHEMA.JOBS).

## Examples

### Insert literal rows with a column list

```
INSERT INTO `project.dataset.plans` (plan_id, name, monthly_price, created_at)
VALUES
  ('free', 'Free', 0, CURRENT_TIMESTAMP()),
  ('pro', 'Pro', 49, CURRENT_TIMESTAMP()),
  ('team', 'Team', DEFAULT, CURRENT_TIMESTAMP());
```

### Append one day of aggregated data with INSERT ... SELECT

A daily pipeline step. On-demand it bills the bytes read from `orders`, which the partition filter limits to one day.

```
INSERT INTO `project.dataset.daily_revenue` (day, store_id, orders, revenue)
SELECT
  DATE(created_at) AS day,
  store_id,
  COUNT(*),
  SUM(amount)
FROM `project.dataset.orders`
WHERE DATE(created_at) = '2026-11-22'
  AND status = 'paid'
GROUP BY day, store_id;
```

### Make the daily insert idempotent

Rerunning a plain INSERT doubles the day. Deleting the day first inside one transaction makes the step safe to retry; when the table is partitioned by `day`, the DELETE covers a whole partition and can drop it without scanning bytes.

```
BEGIN TRANSACTION;

DELETE FROM `project.dataset.daily_revenue` WHERE day = '2026-11-22';

INSERT INTO `project.dataset.daily_revenue` (day, store_id, orders, revenue)
SELECT DATE(created_at), store_id, COUNT(*), SUM(amount)
FROM `project.dataset.orders`
WHERE DATE(created_at) = '2026-11-22' AND status = 'paid'
GROUP BY 1, 2;

COMMIT TRANSACTION;
```

### Write into a specific ingestion-time partition

```
INSERT INTO `project.dataset.raw_webhooks` (_PARTITIONTIME, source, payload)
SELECT TIMESTAMP('2026-11-22'), source, payload
FROM `project.dataset.webhooks_backfill`
WHERE received_date = '2026-11-22';
```

## Common mistakes

*   Omitting the column list in pipelines. `INSERT INTO t SELECT ...` matches by position, so a reordered or added column shifts values into the wrong columns when the types happen to be compatible.
*   Inserting row by row from an application. Each statement is a job; beyond 1,500 INSERTs per table per day they queue, and the queue holds at most 100. Batch rows or use the Storage Write API.
*   Rerunning a failed pipeline step and creating duplicates. INSERT has no conflict handling and keys are not enforced; delete the slice first in a transaction, or use MERGE.
*   Using `INSERT ... ON CONFLICT` or `ON DUPLICATE KEY UPDATE` from PostgreSQL or MySQL. Neither exists in BigQuery; write a MERGE.
*   Inserting into an ingestion-time partitioned table without a column list or with a `_PARTITIONTIME` that is not a partition boundary, such as `TIMESTAMP('2026-11-22 10:30:00')` for a daily table. Both fail.

## Cost and performance

*   On-demand, an INSERT bills only the bytes its SELECT reads; unlike UPDATE, DELETE and MERGE it does not also bill the size of the target table. An INSERT ... VALUES reads no table.
*   DML statements do not count toward the 1,500 table modifications per day that load and query jobs use, but they have their own limits: 25 DML statements per table every 10 seconds, and INSERT concurrency drops to 10 after the first 1,500 INSERTs in 24 hours.
*   Appending to a partitioned table only makes the touched partitions active again; older partitions keep long-term storage pricing. Overwriting the whole table with CREATE OR REPLACE resets all of them.

## FAQ

How do I insert multiple rows in BigQuery?

List several tuples after VALUES: `INSERT INTO t (a, b) VALUES (1, 'x'), (2, 'y')`, or use `INSERT INTO t (a, b) SELECT ...` to insert a query result.

Is there a limit on INSERT statements in BigQuery?

There is no daily cap on DML statements, but after 1,500 INSERTs on one table within 24 hours, only 10 run concurrently and up to 100 queue; more fail. Up to 25 DML statements per table are accepted every 10 seconds.

How do I insert only rows that don't exist yet?

Use `MERGE ... WHEN NOT MATCHED THEN INSERT`, or `INSERT ... SELECT ... WHERE NOT EXISTS (SELECT 1 FROM target WHERE target.id = source.id)`.

## Related

[MERGE](https://mastheadata.com/bigquery/sql/merge.md)[UPDATE](https://mastheadata.com/bigquery/sql/update.md)[DELETE](https://mastheadata.com/bigquery/sql/delete.md)[LOAD DATA](https://mastheadata.com/bigquery/sql/load-data.md)[CREATE TABLE](https://mastheadata.com/bigquery/sql/create-table.md)[WITH (CTE)](https://mastheadata.com/bigquery/sql/with.md)[TRUNCATE TABLE](https://mastheadata.com/bigquery/sql/truncate-table.md)

### Errors you may hit

[Too many DML statements outstanding against table](https://mastheadata.com/bigquery/errors/too-many-dml-statements-outstanding.md)[Provided Schema does not match Table](https://mastheadata.com/bigquery/errors/provided-schema-does-not-match-table.md)[Could not cast literal to type](https://mastheadata.com/bigquery/errors/could-not-cast-literal.md)

[All BigQuery DML statements](https://mastheadata.com/bigquery/dml.md) · [All statements and clauses](https://mastheadata.com/bigquery/sql.md) · [BigQuery error messages](https://mastheadata.com/bigquery/errors.md)
---

## Other pages in sql

> For the full index of this section, see [BigQuery Reference](https://mastheadata.com/llms/llms-bigquery-reference.txt).

- [BigQuery ALTER TABLE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/alter-table.md): ALTER TABLE changes a BigQuery table without rewriting it: ADD COLUMN, DROP COLUMN, RENAME TO, RENAME COLUMN, SET OPTIONS (expiration, description, labels, partition filter) and ALTER COLUMN SET DATA TYPE for widening changes such as INT64 to NUMERIC. These are metadata changes and process no bytes.
- [BigQuery CLUSTER BY: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/cluster-by.md): CLUSTER BY sorts a BigQuery table's storage blocks by up to four columns, so queries that filter on those columns skip blocks and bill fewer bytes. Use it on large tables filtered by columns such as customer_id or status, usually on top of date partitioning.
- [BigQuery CREATE FUNCTION: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/create-function.md): CREATE FUNCTION defines a user-defined function (UDF) in SQL or JavaScript. CREATE TEMP FUNCTION lives for one query or script; CREATE FUNCTION dataset.name is persistent and shared. Prefer SQL UDFs: they are inlined, while JavaScript UDFs use more slots and lack 64-bit integers.
- [BigQuery CREATE MATERIALIZED VIEW: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/create-materialized-view.md): CREATE MATERIALIZED VIEW stores the result of an aggregation over a BigQuery table and keeps it current automatically. Queries read the small precomputed result plus recent changes instead of rescanning the base table, cutting cost for dashboards that repeat the same GROUP BY.
- [BigQuery CREATE TABLE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/create-table.md): CREATE TABLE creates a BigQuery table from a column list, from a query (CREATE TABLE AS SELECT), or both, with optional partitioning, clustering and OPTIONS such as expiration and description. Add OR REPLACE to overwrite a table or IF NOT EXISTS to skip one that exists.
- [BigQuery CREATE TEMP TABLE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/create-temp-table.md): CREATE TEMP TABLE stores intermediate results in a table that exists only for the current multi-statement query or session, without a dataset. Use it to compute an expensive step once and reuse it, instead of a CTE that BigQuery re-runs at every reference.
- [BigQuery CREATE VIEW: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/create-view.md): CREATE VIEW saves a query under a table-like name. A BigQuery view stores no data and re-runs its query on every use, billed for the underlying tables' bytes. Authorize the view on the source dataset to share a filtered subset without granting access to the tables.
- [BigQuery DECLARE and SET: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/declare-set.md): DECLARE creates a variable in a BigQuery multi-statement query and SET assigns it: DECLARE run_date DATE DEFAULT CURRENT_DATE(); SET run_date = '2026-11-22'. Variables make scripts reusable, and a date variable in a WHERE clause still prunes partitions.
- [BigQuery DELETE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/delete.md): DELETE removes the rows of a BigQuery table that match a WHERE clause, which is mandatory. A DELETE that covers whole partitions and filters only on the partitioning column can drop them without scanning bytes; any other DELETE bills the bytes read plus the size of the table or partitions it rewrites.
- [BigQuery EXECUTE IMMEDIATE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/execute-immediate.md): EXECUTE IMMEDIATE runs a SQL statement built as a string at run time, with values bound through USING and results stored with INTO. Use it for dynamic table names, generated PIVOT column lists and maintenance across many tables; bind values as parameters, never by concatenation.
- [BigQuery EXPORT DATA: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/export-data.md): EXPORT DATA writes the result of a query to files in Cloud Storage (CSV, JSON, Avro or Parquet), or to Bigtable, Spanner, Pub/Sub or AlloyDB. The export itself is free; you pay for the query that produces the data, and the URI must contain one  wildcard.
- [BigQuery GROUP BY ROLLUP, CUBE and GROUPING SETS: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/group-by-rollup.md): ROLLUP, CUBE and GROUPING SETS compute several GROUP BY levels in one query: ROLLUP(a, b) adds subtotals per a and a grand total, CUBE(a, b) adds every combination, and GROUPING SETS lists the exact groupings you want. GROUPING() tells subtotal rows from real NULLs.
- [BigQuery INFORMATION_SCHEMA.JOBS: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/information-schema-jobs.md): INFORMATION_SCHEMA.JOBS lists every BigQuery job in a project for the last 180 days, with bytes billed, slot milliseconds, errors and query text. Query it to find the most expensive queries, attribute cost by user or label, and turn total_bytes_billed into an on-demand cost estimate.
- [BigQuery INFORMATION_SCHEMA: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/information-schema.md): INFORMATION_SCHEMA is BigQuery's set of read-only metadata views for tables, columns, partitions, storage and jobs. Query mydataset.INFORMATION_SCHEMA.TABLES or region-us.INFORMATION_SCHEMA.TABLE_STORAGE to audit schemas, find large tables and estimate storage cost. Each on-demand query bills at least 10 MB.
- [BigQuery JOIN: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/join.md): JOIN combines rows of two tables on a condition: INNER JOIN keeps matches, LEFT, RIGHT and FULL OUTER JOIN also keep unmatched rows with NULLs, and CROSS JOIN pairs every row with every row. In BigQuery a comma or CROSS JOIN with UNNEST flattens an array column.
- [BigQuery LOAD DATA: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/load-data.md): LOAD DATA loads files from Cloud Storage (CSV, JSON, Avro, Parquet, ORC) into a BigQuery table from SQL: LOAD DATA INTO appends, LOAD DATA OVERWRITE replaces, and a missing table is created. If the load fails, the table is left unchanged.
- [BigQuery LOOP, WHILE and FOR...IN: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/loops.md): BigQuery scripts loop with LOOP ... END LOOP (exit with BREAK or LEAVE), WHILE condition DO ... END WHILE, REPEAT ... UNTIL ... END REPEAT, and FOR row IN (query) DO ... END FOR. Use them for backfills and maintenance, not row-by-row processing: each statement inside runs as its own job.
- [BigQuery MERGE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/merge.md): MERGE updates, inserts and deletes rows of a BigQuery table in one atomic statement, by matching it against a source table or query. It is BigQuery's upsert: WHEN MATCHED THEN UPDATE, WHEN NOT MATCHED THEN INSERT, and WHEN NOT MATCHED BY SOURCE THEN DELETE for rows that disappeared.
- [BigQuery PARTITION BY (partitioned tables): Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/partition-by.md): PARTITION BY in CREATE TABLE splits a BigQuery table into partitions by a DATE, TIMESTAMP or DATETIME column, by ingestion time, or by integer ranges. Queries that filter on the partitioning column read and bill only the matching partitions, which makes it the main lever on query cost.
- [BigQuery PIVOT: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/pivot.md): PIVOT turns row values into columns with an aggregate: PIVOT(SUM(revenue) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4')) gives one revenue column per quarter. The IN list must be constants, so build it with EXECUTE IMMEDIATE when the values are dynamic.
- [BigQuery QUALIFY: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/qualify.md): QUALIFY filters rows on the result of a window function, the way HAVING filters on aggregates. Use it to keep the latest row per key or the top N per group without a subquery: QUALIFY ROW_NUMBER() OVER (PARTITION BY id ORDER BY updated_at DESC) = 1.
- [BigQuery SELECT * EXCEPT: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/select-except.md): SELECT  EXCEPT (col1, col2) returns every column except the ones you list. In BigQuery it also lowers on-demand cost, because excluded columns are not read: dropping a wide payload or blob column from SELECT  can cut the bytes billed by most of the table.
- [BigQuery SELECT * REPLACE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/select-replace.md): SELECT  REPLACE (expression AS column) returns every column but swaps the value of the named columns for an expression, keeping their names and positions. Use it to mask, round, cast or clean a few columns without listing all the others.
- [BigQuery TABLESAMPLE SYSTEM: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/tablesample.md): TABLESAMPLE SYSTEM (n PERCENT) reads a random subset of a BigQuery table's storage blocks instead of the whole table, so exploratory queries on large tables scan and bill only about n percent of the bytes. Results are approximate and change on every run.
- [BigQuery TRUNCATE TABLE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/truncate-table.md): TRUNCATE TABLE removes every row from a BigQuery table but keeps its schema, partitioning, clustering, description and labels. It is a metadata operation, so it costs nothing, unlike DELETE WHERE TRUE, which is billed as DML.
- [BigQuery UNION ALL and UNION DISTINCT: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/union.md): UNION ALL stacks the rows of two queries; UNION DISTINCT does the same and removes duplicates. BigQuery requires the ALL or DISTINCT keyword, matches columns by position unless you add BY NAME, and also offers INTERSECT DISTINCT and EXCEPT DISTINCT.
- [BigQuery UNPIVOT: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/unpivot.md): UNPIVOT turns columns into rows: UNPIVOT(amount FOR month IN (jan, feb, mar)) gives one row per month with its value in amount. Rows whose value is NULL are dropped unless you add INCLUDE NULLS.
- [BigQuery UPDATE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/update.md): UPDATE changes column values in existing BigQuery rows. The WHERE clause is mandatory (use WHERE TRUE to update every row), and UPDATE ... FROM joins another table. On-demand it bills the bytes read plus the full size of the table, or of the partitions being updated.
- [BigQuery WITH RECURSIVE: Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/with-recursive.md): WITH RECURSIVE defines a CTE that references itself, so a query can walk hierarchies and graphs of unknown depth: org charts, category trees, dependency lineage. BigQuery stops a recursive CTE with an error after 500 iterations.
- [BigQuery WITH (CTE): Syntax and Examples | Masthead](https://mastheadata.com/bigquery/sql/with.md): WITH defines named subqueries (common table expressions) that the rest of a query can reference like tables. In BigQuery a non-recursive CTE is not materialized: each reference runs it again, so a CTE over a large table used three times is scanned and billed three times.
- [BigQuery SQL Syntax: Statements, Clauses, DDL and DML | Masthead](https://mastheadata.com/bigquery/sql.md): BigQuery SQL syntax reference: QUALIFY, PIVOT, MERGE, CTEs, partitioned and clustered tables, scripting and INFORMATION_SCHEMA. 31 statements and clauses with examples and cost notes.
