Click to copy

• Reviewed for ksqlDB 0.29

How to Insert Rows into a Table in ksqlDB

This is an example of adding a new row or record to a ksqlDB table:

INSERT INTO scores_table (
  student_id,
  name,
  score
) VALUES (
  1,
  'Alice',
  4
);

The scores_table was created with the statement below:

CREATE TABLE scores_table (
  student_id BIGINT PRIMARY KEY,
  name STRING,
  score DOUBLE
) WITH (
  KAFKA_TOPIC = 'scores_topic',
  VALUE_FORMAT = 'JSON',
  PARTITIONS = 10
);
You can run INSERT statements regardless if a table is materialized or not. What you cannot do though, is to insert records into a table marked with the SOURCE modifier when it was created. See an example here.
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