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 Data retention time in a topic. A positive number followed by a unit of time.
The following units are supported:
  • s – seconds;
  • m – minutes;
  • h – hours;
  • d – days.
The default value is 18h.
--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 consumed space may exceed the set value when autopartitioning is enabled.
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