# DROP

> Every DROP form the engine accepts — tables, indexes, views, materialized views, transformations, sources, credentials, access and users.

Each object kind has its own `DROP` form. Use the form that matches the object.

| Statement | `IF EXISTS` | Removes |
| --- | --- | --- |
| `DROP TABLE <name>` | yes | A table and its data. |
| `DROP INDEX <index> ON <table>` | yes | One secondary index. |
| `DROP VIEW <name>` | yes | A logical view. |
| `DROP MATERIALIZED VIEW <name>` | yes | A materialized view or template and its engine-owned rows. |
| `DROP MATERIALIZATION <name>` | yes | One instance of a materialized view template. |
| `DROP TRANSFORMATION <name>` | yes | A transformation; its target table stays. |
| `DROP SOURCE <name>` | no | A federated source and its external relations. |
| `DROP CREDENTIAL <uuid>` | no | A stored federation credential. |
| `DROP APPLICATION ACCESS <name>` | no | An application access. |
| `DROP USER <name>` | no | Disables a user. |
| `DROP API KEY <label> FOR USER <name>` | no | Disables an API key. |

With `IF EXISTS`, a missing object is a successful no-op. Each statement drops one object.

## Tables

```sql
DROP TABLE transfers;
```

Views and definitions that read a table are dropped before the table.

```sql
DROP TABLE IF EXISTS transfers;
```

## Indexes

```sql
DROP INDEX transfers_ts ON transfers;
```

```sql
DROP INDEX IF EXISTS transfers_ts ON transfers;
```

The table name is part of the statement: an index is named within its table.

## Views

```sql
DROP VIEW token_volume;
```

```sql
DROP VIEW IF EXISTS token_volume;
```

The `IF EXISTS` form on a missing view answers success with `"applied":false`.

## Materialized views and materializations

Materializations of a template are dropped before the template.

```sql
DROP MATERIALIZATION balances_chain_1;
```

```sql
DROP MATERIALIZED VIEW balances_by_chain;
```

After the drop, reading the name answers HTTP 404.

## Transformations

```sql
DROP TRANSFORMATION balance_activity;
```

```sql
DROP TRANSFORMATION IF EXISTS balance_activity;
```

Dropping a transformation stops the writer. The target table keeps its rows.

## Federation objects

Federation statements run on a WebSocket session. See
[Federation](/docs/sql/federation) for the statements that create these objects.

```sql
DROP SOURCE ledger
```

```sql
DROP CREDENTIAL 6f1c2d3e-4a5b-4c6d-8e9f-0a1b2c3d4e5f
```

A credential belongs to the tenant that imported it. After it is dropped, its credential file is
removed.

```sql
DROP APPLICATION ACCESS analytics_reader
```

Dropping an application access removes its authentication policy.

## Users and API keys

`DROP USER` and `DROP API KEY` disable the credential; the sessions that depend on it end on
their next operation. See [Users and API keys](/docs/sql/users-and-keys).

```sql
DROP USER analyst
```

```sql
DROP API KEY reporting FOR USER analyst
```

After `DROP API KEY`, the key's secret no longer signs in.

---

Source: https://nyxdb.io/docs/sql/drop/
