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 The number of topic partitions.
The default value is 1.
--retention-period-hours Data retention time in a topic, set in hours.
The default value is 18.
--partition-write-speed-kbps The maximum write speed to a partition, specified in KB/s.
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 default value is 0 (no limit).
--supported-codecs Supported data compression methods. Set with a comma.
The default value is raw.
Possible values:
  • RAW: No compression.
  • ZSTD: zstd compression.
  • GZIP: gzip compression.
  • LZOP: lzop compression.
--metering-mode The topic pricing method for a serverless database.
Possible values:
  • request-units: Based on actual usage.
  • reserved-capacity: Based on dedicated resources.

Examples

Note

The examples use the quickstart profile. To learn more, see Creating a profile to connect to a test database.

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

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

View parameters of the created topic:

ydb -p quickstart scheme describe my-topic

Result:

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