---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://ydb.tech/docs/en/yql/reference/syntax/create-secret.md
  - https://ydb.tech/docs/ru/yql/reference/syntax/create-secret.md
  - href: en/yql/reference/syntax/create-secret.md
    type: text/markdown
    title: Markdown version
  - href: ../../../llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/core/yql/reference/syntax/create-secret.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# CREATE SECRET

The `CREATE SECRET` statement creates a [secret](https://ydb.tech/docs/en/concepts/datamodel/secrets.md).

## Syntax {#syntax}

```sql
CREATE SECRET secret_name
WITH (option = value[, ...])
```

* `secret_name` — the name of the secret to create.
* `option` — command option:
  * `value` — string with the secret value.
  * `inherit_permissions` — when enabled, [rights](https://ydb.tech/docs/en/yql/reference/syntax/grant.md) on the secret are inherited from the directory where the secret is created. When disabled, only the [right](https://ydb.tech/docs/en/yql/reference/syntax/grant.md#permissions-list) `DESCRIBE SCHEMA` is inherited from the directory. The secret owner gets all possible rights on it in any case. Default is `False`.

## Permissions {#permissions}

Creating a secret requires the [right](https://ydb.tech/docs/en/yql/reference/syntax/grant.md#permissions-list) `CREATE TABLE`.

## Examples {#examples}

Create a secret in the database root named `secret_name` with value `secret_value`:

```sql
CREATE SECRET secret_name WITH (value = "secret_value");
```

Create a secret in directory `dir` in the database root named `secret_name` with value `secret_value`. If directory `dir` does not exist, it will be created:

```sql
CREATE SECRET `dir/secret_name` WITH (value = "secret_value");
```

Create a secret in the database root named `secret_name` with value `secret_value` with the same rights as the secret's parent directory:

```sql
CREATE SECRET secret_name WITH (value = "secret_value", inherit_permissions = True);
```

## See also {#see-also}

* [ALTER SECRET](https://ydb.tech/docs/en/yql/reference/syntax/alter-secret.md)
* [DROP SECRET](https://ydb.tech/docs/en/yql/reference/syntax/drop-secret.md)
