---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ydb.tech/docs/en/yql/reference/syntax/alter-secret.md?version=main
  - https://ydb.tech/docs/ru/yql/reference/syntax/alter-secret.md?version=main
sourcePath: en/core/yql/reference/syntax/alter-secret.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# ALTER SECRET

The `ALTER SECRET` statement modifies an existing [secret](https://ydb.tech/docs/en/concepts/datamodel/secrets.md?version=main).

## Syntax {#syntax}

```sql
ALTER SECRET [IF EXISTS] secret_name
WITH (option = value[, ...])
```

* `IF EXISTS` — the statement does not return an error if the secret does not exist; in this case, it is a no-op.
* `secret_name` — the name of the secret to modify.
* `option` — command option:
  * `value` — string with the secret value.

## Permissions {#permissions}

Modifying a secret requires the [right](https://ydb.tech/docs/en/yql/reference/syntax/grant.md?version=main#permissions-list) `ALTER SCHEMA`.

## Examples {#examples}

Change the value of secret `secret_name` to `secret_value_new`:

```sql
ALTER SECRET secret_name WITH (value = "secret_value_new");
```

Change the value of secret `secret_name` to `secret_value_new` only if it exists; if it does not exist, the statement is a no-op:

```sql
ALTER SECRET IF EXISTS secret_name WITH (value = "secret_value_new");
```

## See also {#see-also}

* [CREATE SECRET](https://ydb.tech/docs/en/yql/reference/syntax/create-secret.md?version=main)
* [DROP SECRET](https://ydb.tech/docs/en/yql/reference/syntax/drop-secret.md?version=main)
