---
title: list_secrets table function
description: Learn the syntax of the list\_secrets function of the SQL language in Databricks.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/list_secrets
---

# `list_secrets` table function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL preview ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 11.3 LTS and above

Returns all keys in all scopes or one specific scope the user is authorized to see from [Databricks secret service](https://docs.databricks.com/aws/en/security/secrets/index.md).

## Syntax

```
list_secrets ( [ scopeStr ] )
```

## Arguments

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL preview ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 15.3 and above

* **scopeStr**: The scope within which to search. If not provided, all scopes are returned.

## Returns

A table with two columns:

* `scope STRING NOT NULL`: The namespace of the key.
* `key STRING NOT NULL`: The key itself

To return the secret values for specific keys use [`secret(scope, key)`](https://docs.databricks.com/aws/en/sql/language-manual/functions/secret.md).

## Error conditions

* `INVALID_SECRET_LOOKUP.LIST_SECRETS_FAILED`: Databricks secret service is not available.

## Examples

```sql
> SELECT * FROM list_secrets();
  scope         key
  ------------  ---------------
  secrets.r.us  theAnswerToLife
  openSecrets   psst

> SELECT * FROM list_secrets('secrets.r.us');
  scope         key
  ------------  ---------------
  secrets.r.us  theAnswerToLife

> SELECT secret('secrets.r.us', 'theAnswerToLife');
  fourtyTwo
```

## Related functions

* [`list_secrets` table function](https://docs.databricks.com/aws/en/sql/language-manual/functions/list_secrets.md#)
