# has_database_privilege

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: has_database_privilege
latest-operator-version: v26.2.4
latest-console-tag: v3.12.0
latest-connect-version: 4.113.1
latest-redpanda-tag: v26.2.4
docname: sql/sql-functions/other-functions/has-database-privilege
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/other-functions/has-database-privilege.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/other-functions/has-database-privilege.adoc
description: The `has_database_privilege()` function checks whether a user has specific privileges on a database.
page-topic-type: reference
page-git-created-date: "2026-09-08"
page-git-modified-date: "2026-09-08"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/other-functions/has-database-privilege.md -->

The [`has_database_privilege()`](https://www.postgresql.org/docs/current/functions-info.html#FUNCTIONS-INFO-ACCESS) function is an access privilege inquiry function that checks whether a user has specific privileges on a database. It checks the named `user` (or `user_id`) when you provide one, and the current user when you omit it.

## [](#syntax)Syntax

The `has_database_privilege()` function has three available syntax versions:

```sql
SELECT has_database_privilege('user', 'database', 'privilege');
```

```sql
SELECT has_database_privilege(user_id, 'database', 'privilege');
```

```sql
SELECT has_database_privilege('database', 'privilege');
```

The function returns a boolean value: `TRUE` if the user has the specified privilege, `FALSE` otherwise.

## [](#parameters)Parameters

-   `database`: Name of the database to check privileges for (can be any string value or string columns from other tables).

-   `user`: Name of the user who has the privileges (can be any string value).

-   `user_id`: OID of the user who has the privileges (can be any integer value), as an alternative to `user`.

-   `privilege`: Specifies the privilege to check for on the database.


> 📝 **NOTE**
>
> The comparison for the `privilege` is case-insensitive, so you can use lowercase or uppercase notation for the privilege name.

## [](#examples)Examples

### [](#check-the-current-users-privilege-on-a-database)Check the current user’s privilege on a database

This example uses the `has_database_privilege()` function to determine whether the current user has a privilege on the `redpanda` database, without naming a user explicitly:

```sql
SELECT has_database_privilege('redpanda', 'connect');
```

The query returns `TRUE`, which means that the current user has the `connect` privilege on the `redpanda` database.

```sql
 has_database_privilege
------------------------
 t
```

### [](#check-another-users-privilege-on-a-database)Check another user’s privilege on a database

Use the `has_database_privilege()` function to check a named user’s privilege on a database:

```sql
SELECT has_database_privilege('cahyo', 'redpanda', 'connect');
```

The query returns `TRUE`, which means the named user has the `connect` privilege on the `redpanda` database.

```sql
 has_database_privilege
------------------------
 t
```