# pgusers

## Description

Exposes metadata about pguser credentials in the organization. Pgusers are PostgreSQL-compatible credentials that allow direct database access using standard PostgreSQL drivers. The credential password is never exposed. Only pgusers on which the current role has USAGE privileges are returned.

{% hint style="info" %}
**Note** Pguser passwords are never returned by this table. Only the username and metadata are accessible.
{% endhint %}

## Syntax

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

## Columns

| Column                    | Type           | Nullable | Description                                                                            |
| ------------------------- | -------------- | -------- | -------------------------------------------------------------------------------------- |
| `organization_id`         | VARCHAR        | No       | The unique identifier of the organization this resource belongs to.                    |
| `name`                    | VARCHAR        | No       | User-defined name for the pguser credential.                                           |
| `role_name`               | VARCHAR        | No       | The DeltaStream role associated with this pguser.                                      |
| `username`                | VARCHAR        | No       | The PostgreSQL-compatible username generated for this credential (e.g. `dspg_<hash>`). |
| `expires_at`              | TIMESTAMP\_LTZ | Yes      | Expiry timestamp for the credential, or null if it does not expire.                    |
| `owner`                   | VARCHAR        | No       | The role that owns this resource.                                                      |
| `created_by_role`         | VARCHAR        | No       | The role that created this resource.                                                   |
| `created_by_role_deleted` | BOOLEAN        | No       | Whether the creating role has since been deleted.                                      |
| `created_by`              | VARCHAR        | No       | The user that created this resource.                                                   |
| `created_at`              | TIMESTAMP\_LTZ | No       | Timestamp when this resource was created.                                              |
| `updated_by_role`         | VARCHAR        | Yes      | The role that last updated this resource.                                              |
| `updated_by_role_deleted` | BOOLEAN        | Yes      | Whether the last updating role has since been deleted.                                 |
| `updated_by`              | VARCHAR        | Yes      | The user that last updated this resource.                                              |
| `updated_at`              | TIMESTAMP\_LTZ | No       | Timestamp when this resource was last updated.                                         |

## Examples

```sh
$ dsql -e 'SELECT * FROM deltastream.sys."pgusers";'
[{"organization_id":"00000000-0000-0000-0000-000000000001","name":"test","role_name":"sysadmin","username":"dspg_b6b2a6a36cb54e50a8a89c13c3527cf2","expires_at":null,"owner":"sysadmin","created_by_role":"sysadmin","created_by_role_deleted":false,"created_by":"user@example.com","created_at":"2026-01-07T20:39:27.914Z","updated_by_role":null,"updated_by_role_deleted":null,"updated_by":null,"updated_at":"2026-01-07T20:39:27.914Z"}]
```

## See Also

* [System Tables Overview](https://docs.deltastream.io/reference/sql-syntax/systables)
