Skip to Content
Tables & SQLQuerying & Modifying Data

Querying and Modifying KalamDB Data

Use KalamDB SQL to create a task, find it, mark it complete, and remove it. First create the private todo table.

Query KalamDB todos

SQL
INSERT INTO app.todos (title) VALUES ('Learn live queries');SELECT id, title, completed FROM app.todos;

Copy the returned task ID into the following statements in place of 123:

SQL
UPDATE app.todos SET completed = TRUE WHERE id = 123;SELECT id, title, completed FROM app.todos WHERE id = 123;DELETE FROM app.todos WHERE id = 123;

The second query returns the updated task. After the delete, querying that ID returns no rows.

SQL
BEGIN;INSERT INTO app.todos (title) VALUES ('Create a schema');INSERT INTO app.todos (title) VALUES ('Connect the UI');COMMIT;

Use ROLLBACK instead of COMMIT to discard the transaction. Consult the SQL reference for supported transaction behavior and limits.

Common mistakes

In application code, bind values using your SDK’s query parameters. Do not concatenate user text into SQL. Keep the row ID when rendering a list so updates and deletes address the intended row.

Next step

Make the task list realtime →

Reference: SQL queries and transactions.