# DB2 DB2 Permissions

Source: https://userguide.qualytics.io/source-datastore/datastore/jdbc/db2/permissions/

> **Info: Permissions in your DB2**
>
> The permissions on this page are granted in your own DB2, to the account Qualytics connects with, by whoever administers DB2 at your company. They let Qualytics connect the datastore and read your data, and write to it when it is an enrichment datastore. They are not Qualytics roles or team permissions. To know which Qualytics user role (**Admin**, **Manager**, or **Member**) and team permission you need to connect the datastore in Qualytics, see [Source Datastore Permissions](https://userguide.qualytics.io/source-datastore/datastore/deep-dive/permissions/).

Qualytics connects to DB2 through the **IBM DB2 JDBC driver**. It queries DB2 system catalogs (`SYSCAT.SCHEMATA`, `SYSCAT.TABLES`) to discover schemas and uses standard JDBC metadata APIs for tables, columns, and primary keys.

## Minimum DB2 Permissions (Source Datastore)

| Permission | Purpose |
| --- | --- |
| `CONNECT ON DATABASE` | Allow the user to connect to the database |
| `USAGE ON SCHEMA <schema_name>` | Access objects within the target schema |
| `SELECT ON ALL TABLES IN SCHEMA` | Read data from all tables for profiling and scanning |
| `SELECT ON SYSCAT.SCHEMATA` | Discover available schemas in the database |
| `SELECT ON SYSCAT.TABLES` | Discover available tables and filter empty schemas |

## Additional Permissions for an Enrichment Datastore

When DB2 is used as an enrichment datastore, the following additional permissions are required so Qualytics can write its outputs, which are named from the linked source's prefix (for example `_tpch_failed_checks`):

| Permission | Purpose |
| --- | --- |
| `CREATETAB ON DATABASE` | Create enrichment outputs |
| `CREATEIN ON SCHEMA <schema_name>` | Create new objects within the schema |
| `ALTERIN ON SCHEMA <schema_name>` | Modify enrichment table schemas during version migrations |
| `INSERT ON ALL TABLES IN SCHEMA` | Write anomaly records, scan results, and check metrics |
| `UPDATE ON ALL TABLES IN SCHEMA` | Update enrichment records during rescans |
| `DELETE ON ALL TABLES IN SCHEMA` | Replace records when a run overwrites an output |
| `DROPIN ON SCHEMA <schema_name>` | Replace an output when a run overwrites it (Overwrite remediation, Materialize, Export) or when a schema change requires recreating it. Unlinking never removes written data |

## Example: Source Datastore User (Read-Only)

Replace `<schema_name>` with your actual value.

```sql
-- Grant connection and schema access
GRANT CONNECT ON DATABASE TO USER qualytics_read;
GRANT USAGE ON SCHEMA <schema_name> TO USER qualytics_read;

-- Grant read access to all tables in the schema
GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> TO USER qualytics_read;
```

## Example: Enrichment Datastore User (Read-Write)

```sql
-- Grant connection and schema access
GRANT CONNECT ON DATABASE TO USER qualytics_readwrite;
GRANT USAGE ON SCHEMA <schema_name> TO USER qualytics_readwrite;

-- Grant full data manipulation on all tables
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA <schema_name> TO USER qualytics_readwrite;

-- Grant table creation and schema modification
GRANT CREATETAB ON DATABASE TO USER qualytics_readwrite;
GRANT CREATEIN ON SCHEMA <schema_name> TO USER qualytics_readwrite;
GRANT ALTERIN ON SCHEMA <schema_name> TO USER qualytics_readwrite;
```

> **Note**
>
> Qualytics queries DB2 system catalogs (`SYSCAT.SCHEMATA`, `SYSCAT.TABLES`) during schema discovery. Ensure the Qualytics user has `SELECT` access to these system catalog views.

*Last updated: November 16, 2026.*
