Click to copy

• Reviewed for ksqlDB 0.29

How to Create Topic in ksqlDB

In ksqlDB, you create a topic by creating a stream where the topic set as KAFKA_TOPIC doesn't exist yet. Here is an example:

CREATE STREAM flights (
  flight_id STRING
) WITH (
  KAFKA_TOPIC = 'flights_topic',
  PARTITIONS = 10,
  REPLICAS = 3
);

You can set the number of partitions and the replication factor inside the WITH clause using the PARTITIONS and REPLICAS stream properties respectively. If not set, the default values set at the Apache Kafka brokers will be used.

Creating a bare topic

If you are only interested in creating the topic, you can drop the stream by running:

DROP STREAM flights;

without the modifier DELETE TOPIC.

Discover what readers are saying
topictale
Get easy to digest how-tos on ksqlDB
Sign up
Please read our Privacy Policy to understand how we protect and manage your data.
You may also like