Creating a topic

You can use the topic create subcommand to create a new topic.

General format of the command:

ydb [global options...] topic create [options...] <topic-path>

View the description of the create topic command:

ydb topic create --help

Parameters of the subcommand

Name Description
--partitions-count VAL The number of topic partitions.
The default value is 1.
--retention-period-hours VAL Data retention time in a topic, set in hours.
The default value is 18.
--supported-codecs STRING Supported data compression methods.
The default value is raw,zstd,gzip,lzop.
Possible values:
  • RAW: Without compression.
  • ZSTD: zstd compression.
  • GZIP: gzip compression.
  • LZOP: lzop compression.



The examples use the db1 profile. To learn more, see Creating a connection profile.

Create a topic with 2 partitions, RAW and GZIP compression methods, message retention time of 2 hours, and the my-topic path:

ydb -p db1 topic create \
  --partitions-count 2 \
  --supported-codecs raw,gzip \
  --retention-period-hours 2 \

View parameters of the created topic:

ydb -p db1 scheme describe my-topic


RetentionPeriod: 2 hours
PartitionsCount: 2
SupportedCodecs: RAW, GZIP