Click to copy

• Reviewed for ksqlDB 0.29

How to Create an Empty Table in ksqlDB

Example of creating an empty table:

CREATE TABLE scores_empty_table (
  student_id BIGINT PRIMARY KEY,
  name STRING,
  score DOUBLE
) WITH (
  KAFKA_TOPIC = 'scores_topic',
  VALUE_FORMAT = 'JSON',
  PARTITIONS = 10
);
The PARTITIONS property tells ksqlDB to create a new topic instead of looking for an existing one.

This statement creates a non-materialized table named scores_table along with a new topic named scores_topic.

You can use non-materialized tables a s sources for persistent and push queries, but you can’t run pull queries on them. Read about how to materialize a table.

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