# relation\_columns

## Description

Exposes the column definitions for all relations (streams, changelogs, tables, materialized views) in the organization. This is the programmatic equivalent of DESCRIBE RELATION COLUMNS and can be used to introspect schemas dynamically. Access requires the same privileges as the parent relation.

## Syntax

```sql
SELECT * FROM deltastream.sys."relation_columns";
```

## Columns

| Column            | Type    | Nullable | Description                                                                   |
| ----------------- | ------- | -------- | ----------------------------------------------------------------------------- |
| `relation_name`   | VARCHAR | No       | Name of the relation this column belongs to.                                  |
| `schema_name`     | VARCHAR | No       | Schema containing the relation.                                               |
| `database_name`   | VARCHAR | No       | Database containing the relation.                                             |
| `name`            | VARCHAR | No       | Column name.                                                                  |
| `type`            | VARCHAR | No       | DeltaStream data type of the column, e.g. `VARCHAR`, `BIGINT`, `STRUCT<...>`. |
| `properties`      | VARCHAR | No       | JSON object of column-level properties.                                       |
| `relation_id`     | VARCHAR | No       | Unique identifier of the parent relation.                                     |
| `organization_id` | VARCHAR | No       | The unique identifier of the organization this resource belongs to.           |

## Examples

List all columns across all relations:

```sql
SELECT * FROM deltastream.sys."relation_columns";
```

```sh
[{"relation_name":"mcp_logging","schema_name":"public","database_name":"mview_test","name":"logtime","type":"VARCHAR","properties":"{}","organization_id":"00000000-0000-0000-0000-000000000001","relation_id":"019cb1c4-db72-7541-88d0-f321ebe8db87"},{"relation_name":"mcp_logging","schema_name":"public","database_name":"mview_test","name":"logtype","type":"VARCHAR","properties":"{}","organization_id":"00000000-0000-0000-0000-000000000001","relation_id":"019cb1c4-db72-7541-88d0-f321ebe8db87"}]
```

Filter columns for a specific relation:

```sql
SELECT name, type FROM deltastream.sys."relation_columns" WHERE database_name = 'mydb' AND schema_name = 'public' AND relation_name = 'pageviews_s3';
```

## See Also

* [System Tables Overview](https://docs.deltastream.io/reference/sql-syntax/systables)
* [DESCRIBE RELATION COLUMNS](https://docs.deltastream.io/reference/sql-syntax/command/describe-relation-columns)
* [relations](https://docs.deltastream.io/reference/sql-syntax/systables/relations)
