> ## Documentation Index
> Fetch the complete documentation index at: https://docs.narrative.io/llms.txt
> Use this file to discover all available pages before exploring further.

# DELETE

> Reference for the DELETE statement

The `DELETE` statement removes rows from a dataset. A `WHERE` clause restricts which rows are removed.

<Note>
  DELETE runs against datasets you own. To drop an entire dataset rather than delete rows, delete the dataset through the platform UI or API.
</Note>

## Syntax

```sql theme={null}
DELETE FROM table_reference
[WHERE condition]
```

* The `WHERE` clause is optional. If omitted, **every row in the dataset is removed**. The dataset itself remains but is empty.
* The `WHERE` condition can reference any column on the target dataset and use any NQL [operators](/nql/operators) or [functions](/nql/functions/index).
* The `WHERE` condition can reference only the target dataset. Subqueries that read from another dataset (for example, `WHERE name IN (SELECT name FROM company_data."456")`) are not supported.

## Examples

**Delete a single row by key:**

```sql theme={null}
DELETE FROM company_data."123"
WHERE user_id = 42
```

**Delete rows matching a condition:**

```sql theme={null}
DELETE FROM company_data.pipeline_log
WHERE
  status = 'stale'
  AND created_at < CURRENT_TIMESTAMP - INTERVAL '90' DAY
```

**Delete rows with null required fields:**

```sql theme={null}
DELETE FROM company_data."123"
WHERE email IS NULL
```

## Execution context

DELETE statements can run in two places:

| Execution surface                                                                      | When to use                                         |
| -------------------------------------------------------------------------------------- | --------------------------------------------------- |
| NQL query endpoint                                                                     | Ad-hoc deletes from an API client or Data Studio    |
| [`ExecuteDml` workflow task](/guides/workflows/workflow-orchestration#supported-tasks) | Scheduled or event-driven deletes inside a workflow |

<Warning>
  DELETE is irreversible. Running `DELETE FROM table_reference` without a `WHERE` clause empties the dataset. Run the equivalent `SELECT` with the same predicate first to confirm exactly which rows will be removed.
</Warning>

***

## Related content

<CardGroup cols={2}>
  <Card title="INSERT" icon="plus" href="/nql/commands/insert">
    Add rows to a dataset
  </Card>

  <Card title="UPDATE" icon="pen" href="/nql/commands/update">
    Modify existing rows in a dataset
  </Card>

  <Card title="SELECT" icon="magnifying-glass" href="/nql/commands/select">
    Preview rows before deleting
  </Card>

  <Card title="ExecuteDml workflow task" icon="diagram-project" href="/guides/workflows/workflow-orchestration#supported-tasks">
    Run DML statements from a workflow
  </Card>
</CardGroup>
