# System Tables

System tables are read-only relations in the `deltastream.sys` virtual schema that expose metadata about your DeltaStream organization. They can be queried using standard SQL `SELECT` statements, which makes them useful for programmatic access, automation, and agents that need to inspect or reason about the state of your DeltaStream resources.

## Syntax

```sql
SELECT column [, ...]
FROM deltastream.sys."<table_name>"
[ WHERE condition ]
[ ORDER BY column ]
[ LIMIT n ];
```

## Description

System tables provide the same information as the corresponding `LIST` and `DESCRIBE` commands, but as queryable SQL relations. This allows you to filter, sort, join, and aggregate metadata in ways that the dedicated commands do not support.

{% hint style="info" %}
**Note** System table names must be quoted with double quotes, e.g. `deltastream.sys."compute_pools"`.
{% endhint %}

### Access Control

Each system table enforces [role-based access control](https://docs.deltastream.io/overview/core-concepts/access-control) automatically. Rows are filtered to only those resources the current role has `USAGE` privileges on. No additional `WHERE` clause is needed to scope results to the current role.

### Column Types

Columns in system tables use the following DeltaStream types:

| PostgreSQL type           | DeltaStream type |
| ------------------------- | ---------------- |
| `boolean`                 | `BOOLEAN`        |
| `smallint`                | `SMALLINT`       |
| `integer`                 | `INTEGER`        |
| `bigint`                  | `BIGINT`         |
| `varchar`, `text`, `uuid` | `VARCHAR`        |
| `timestamptz`             | `TIMESTAMP_LTZ`  |

## Available System Tables

| Table                                                                                                                 | Description                                                     |
| --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [`audit_logs`](https://docs.deltastream.io/reference/sql-syntax/systables/audit-logs)                                 | Audit log of all actions performed in the organization          |
| [`compute_pools`](https://docs.deltastream.io/reference/sql-syntax/systables/compute-pools)                           | Compute pools defined in the organization                       |
| [`databases`](https://docs.deltastream.io/reference/sql-syntax/systables/databases)                                   | Databases in the organization                                   |
| [`descriptor_sources`](https://docs.deltastream.io/reference/sql-syntax/systables/descriptor-sources)                 | Protobuf descriptor sources                                     |
| [`function_sources`](https://docs.deltastream.io/reference/sql-syntax/systables/function-sources)                     | Function source packages (JARs)                                 |
| [`functions`](https://docs.deltastream.io/reference/sql-syntax/systables/functions)                                   | User-defined functions (UDFs)                                   |
| [`organization_defaults`](https://docs.deltastream.io/reference/sql-syntax/systables/organization-defaults)           | Per-user session defaults (role, database, store, compute pool) |
| [`organization_subscriptions`](https://docs.deltastream.io/reference/sql-syntax/systables/organization-subscriptions) | Subscription plan details for the organization                  |
| [`organizations`](https://docs.deltastream.io/reference/sql-syntax/systables/organizations)                           | Organizations the current user is a member of                   |
| [`pgusers`](https://docs.deltastream.io/reference/sql-syntax/systables/pgusers)                                       | PostgreSQL-compatible user credentials                          |
| [`queries`](https://docs.deltastream.io/reference/sql-syntax/systables/queries)                                       | Streaming queries (active and historical)                       |
| [`query_tags`](https://docs.deltastream.io/reference/sql-syntax/systables/query-tags)                                 | Key/value tags attached to queries                              |
| [`relation_columns`](https://docs.deltastream.io/reference/sql-syntax/systables/relation-columns)                     | Column definitions for all relations                            |
| [`relations`](https://docs.deltastream.io/reference/sql-syntax/systables/relations)                                   | Streams, changelogs, tables, materialized views, and indexes    |
| [`role_privileges`](https://docs.deltastream.io/reference/sql-syntax/systables/role-privileges)                       | Privilege grants for roles                                      |
| [`roles`](https://docs.deltastream.io/reference/sql-syntax/systables/roles)                                           | Roles defined in the organization                               |
| [`schema_registries`](https://docs.deltastream.io/reference/sql-syntax/systables/schema-registries)                   | Schema registry connections                                     |
| [`schemas`](https://docs.deltastream.io/reference/sql-syntax/systables/schemas)                                       | Schemas (namespaces) within databases                           |
| [`secrets`](https://docs.deltastream.io/reference/sql-syntax/systables/secrets)                                       | Secrets (metadata only, values never exposed)                   |
| [`stores`](https://docs.deltastream.io/reference/sql-syntax/systables/stores)                                         | External system connections                                     |
| [`user_grants`](https://docs.deltastream.io/reference/sql-syntax/systables/user-grants)                               | User-to-role membership grants                                  |
| [`userdatas`](https://docs.deltastream.io/reference/sql-syntax/systables/userdatas)                                   | Per-user key/value metadata (internal UI state)                 |
