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.
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, or stream with the Storage Write API. There is no INSERT ... ON CONFLICT and primary keys are not enforced: use MERGE 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 CONFLICTorON DUPLICATE KEY UPDATEfrom PostgreSQL or MySQL. Neither exists in BigQuery; write a MERGE. - Inserting into an ingestion-time partitioned table without a column list or with a
_PARTITIONTIMEthat is not a partition boundary, such asTIMESTAMP('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
Errors you may hit
All BigQuery DML statements · All statements and clauses · BigQuery error messages
