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

# Updating a topic

You can use the `topic alter` subcommand to update a [previously created](https://ydb.tech/docs/en/reference/ydb-cli/topic-create.md) topic.

General format of the command:

```bash
ydb [global options...] topic alter [options...] <topic-path>
```

* `global options`: [Global parameters](https://ydb.tech/docs/en/reference/ydb-cli/commands/global-options.md).
* `options`: [Parameters of the subcommand](#options).
* `topic-path`: Topic path.

View the description of the update topic command:

```bash
ydb topic alter --help
```

## Parameters of the subcommand {#options}

The command changes the values of parameters specified in the command line. The other parameter values remain unchanged.

| Name                           | Description                                                                                                                                                                                                                                                                                                                   |
|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `--partitions-count`           | The number of topic [partitions](../../concepts/datamodel/topic.md#partitioning). You can only increase the number of partitions.                                                                                                                                                                                                       |
| `--retention-period`           | Data retention time in a topic. A positive number followed by a unit of time.<br/>The following units are supported:<ul><li>`s` – seconds;</li><li>`m` – minutes;</li><li>`h` – hours;</li><li>`d` – days.</li></ul>                                                                                                          |
| `--partition-write-speed-kbps` | The maximum write speed to a [partition](../../concepts/datamodel/topic.md#partitioning), specified in KB/s.<br/>The default value is `1024`.                                                                                                                                                                                           |
| `--retention-storage-mb`       | The maximum storage size, specified in MB. When the limit is reached, the oldest data will be deleted. The consumed space may exceed the set value when autopartitioning is enabled.<br/>The default value is `0` (no limit).                                                                                                                                                                               |
| `--supported-codecs`           | Supported data compression methods.<br/>Possible values:<ul><li>`RAW`: No compression.</li><li>`ZSTD`: [zstd](https://en.wikipedia.org/wiki/Zstandard) compression.</li><li>`GZIP`: [gzip](https://en.wikipedia.org/wiki/Gzip) compression.</li><li>`LZOP`: [lzop](https://en.wikipedia.org/wiki/Lzop) compression.</li></ul> |
| `--metering-mode`              | The topic pricing method for a serverless database.<br/>Possible values:<ul><li>`request-units`: Based on actual usage.</li><li>`reserved-capacity`: Based on dedicated resources.</li></ul>                                                                                                                                  |

## Examples {#examples}

<!-- source: en/_includes/ydb-cli-profile.md -->
{% note info %}

The examples use the `quickstart` profile. To learn more, see [Creating a profile to connect to a test database](https://ydb.tech/docs/en/reference/ydb-cli/profile/create.md#quickstart).

{% endnote %}
<!-- endsource: en/_includes/ydb-cli-profile.md -->

Add a partition and the `lzop` compression method to the [previously created](https://ydb.tech/docs/en/reference/ydb-cli/topic-create.md) topic:

```bash
ydb -p quickstart topic alter \
  --partitions-count 3 \
  --supported-codecs raw,gzip,lzop \
  my-topic
```

Make sure that the topic parameters have been updated:

```bash
ydb -p quickstart scheme describe my-topic
```

Result:

```text
RetentionPeriod: 2h
PartitionsCount: 3
SupportedCodecs: RAW, GZIP, LZOP
```
