Request a demo

BigQuery · DML statement

BigQuery DELETE

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.

GoogleSQL for BigQuery · Checked against the official reference in November 2026

DELETE [FROM] table WHERE condition removes matching rows as one implicit transaction. BigQuery requires the WHERE clause; a DELETE without one fails with "DELETE must have a WHERE clause". To empty a table, use TRUNCATE TABLE, which is a free metadata operation, or WHERE TRUE. The condition can use subqueries, such as WHERE customer_id IN (SELECT customer_id FROM gdpr_requests) or WHERE NOT EXISTS (...); there is no DELETE ... USING or DELETE ... JOIN syntax.

The cost depends on what the filter covers. If the table is partitioned and the condition selects whole partitions using only the partitioning column, such as WHERE event_date < '2026-01-01', BigQuery can remove those partitions as a metadata operation, without scanning bytes or using slots; a dry run reporting 0 bytes confirms it. Filters on other columns, subqueries, recently streamed data and tables clustered on other columns can disqualify that shortcut. Otherwise a DELETE is billed like an UPDATE on demand: bytes read by the statement plus the size of the table, or of the partitions it touches, because those partitions are rewritten without the deleted rows.

DELETE is a mutating DML statement: two run concurrently per table, up to 20 more queue, and concurrent DELETEs and UPDATEs on the same partition can fail with Could not serialize access to table due to concurrent update. Rows streamed in the last 30 minutes through tabledata.insertAll cannot be deleted yet. Deleted rows stay recoverable through time travel (FOR SYSTEM_TIME AS OF) for the dataset's time travel window, and on physical storage billing those bytes are still billed during that window and the fail-safe period after it.

Syntax

DELETE [FROM] table_name [[AS] alias]
WHERE condition

Arguments and return value

ArgumentDescription
table_nameThe table to delete from. Not a view or a wildcard table.
conditionRequired. Rows for which it is TRUE are deleted. May contain subqueries; WHERE TRUE deletes every row.

Returns: No result set. Job statistics report deleted_row_count (dml_statistics in INFORMATION_SCHEMA.JOBS).

Examples

Drop old partitions without scanning

events is partitioned by event_date. The condition covers whole partitions and uses only the partitioning column, so BigQuery can delete them as metadata. Check with a dry run: it should report 0 bytes.

DELETE FROM `project.dataset.events`
WHERE event_date < '2025-11-01';

Delete users listed in a GDPR request table

This rewrites every partition that contains a matching user, and on-demand bills the bytes read plus the size of those partitions.

DELETE FROM `project.dataset.events`
WHERE user_id IN (
  SELECT user_id
  FROM `project.privacy.deletion_requests`
  WHERE status = 'approved'
);

Remove duplicate rows, keeping the newest

BigQuery has no row IDs, so a DELETE can't target one of two identical rows. When rows differ in a timestamp, delete all but the latest per key.

DELETE FROM `project.dataset.customers` AS c
WHERE EXISTS (
  SELECT 1
  FROM `project.dataset.customers` AS newer
  WHERE newer.customer_id = c.customer_id
    AND newer.updated_at > c.updated_at
);

Common mistakes

  • Running DELETE without WHERE. It fails with "DELETE must have a WHERE clause"; use TRUNCATE TABLE to empty a table.
  • Deleting exact duplicates with DELETE. Identical rows can't be told apart; rebuild the table with SELECT DISTINCT or QUALIFY ROW_NUMBER() OVER (...) = 1 in a CREATE OR REPLACE TABLE.
  • Using NOT IN (subquery) when the subquery can return NULL. x NOT IN (..., NULL) is never TRUE, so nothing is deleted; use NOT EXISTS.
  • Filtering a partitioned table on a derived expression, such as WHERE FORMAT_DATE('%Y-%m', event_date) = '2025-10'. This loses both pruning and the metadata-only shortcut; compare the bare column with a range.
  • Expecting deleted data to stop costing storage at once. Deleted bytes remain in time travel for the configured window (up to 7 days) and, on physical billing, in fail-safe afterwards.

Cost and performance

  • A whole-partition DELETE on the partitioning column can be free: no bytes scanned, no slots. Partial deletes bill the bytes read plus the size of every partition they rewrite.
  • Setting partition_expiration_days removes old partitions automatically and at no charge, which is cheaper and simpler than a scheduled DELETE.
  • Batch deletions. Each DELETE rewrites the partitions it touches, so 100 single-row DELETEs on one partition rewrite it 100 times; collect the keys in a table and delete them in one statement.

FAQ

How do I delete all rows from a table in BigQuery?

TRUNCATE TABLE project.dataset.t removes all rows as a metadata operation without charge. DELETE FROM t WHERE TRUE also works but is billed as DML.

How do I delete rows based on another table in BigQuery?

Use a subquery in WHERE: DELETE FROM t WHERE id IN (SELECT id FROM other) or WHERE EXISTS (SELECT 1 FROM other o WHERE o.id = t.id). BigQuery has no DELETE ... JOIN or USING.

Can I undo a DELETE in BigQuery?

Within the dataset's time travel window, copy the earlier version into a new table with CREATE TABLE restored AS SELECT * FROM t FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR), then insert the missing rows from it. One statement can't read the same table at two points in time.

Errors you may hit

All BigQuery DML statements · All statements and clauses · BigQuery error messages

Observability for every BigQuery table, in about 15 minutes

Masthead detects freshness, volume and schema anomalies, monitors pipeline errors and maps column-level lineage across all your projects, from logs and metadata only.