> For the complete documentation index, see [llms.txt](https://docs.livestreamiq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.livestreamiq.com/readme/3.-guide-to-navigation/3.4-cluster-overview/3.4.6-ksql-db.md).

# 3.4.6 KSQL DB

It is a streaming database built on top of Apache Kafka that allows you to process and query real-time data using SQL-like queries.

<figure><img src="https://1499573743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6jSyTKzD9UG0uYLYFS7I%2Fuploads%2Fgit-blob-53eb7c287923567da38f5eec2b3266aa7962a18d%2Fimage%20(25).png?alt=media" alt=""><figcaption></figcaption></figure>

#### **To Execute KSQL Request:**

1. Click this button to execute KSQL queries and perform operations on Kafka data.
2. There are two section **Table** and **Streams**.
3. In **Tables** section, it displays the list of tables created in KSQL DB.
   1. **Name**: Name of the KSQL table.
   2. **Topic**: Kafka topic associated with the table.
   3. **Key Format:** Format of the message key (Example: KAFKA).
   4. **Value Format:** Format of the message data (Example: JSON).
   5. **Is Windowed:** Shows whether the table uses windowing or not.
4. In **Streams** section, it displays the list of streams created in KSQL DB.<br>

   ![](https://1499573743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6jSyTKzD9UG0uYLYFS7I%2Fuploads%2Fgit-blob-1d962141d889a9cb965cf620f3194f9625006061%2Funknown%20\(134\).png?alt=media)

   1. **KSQL Editor:** Used to write KSQL queries.
   2. **Stream Properties:**
      1. Key: Defines the key field of the Kafka message.
      2. Value: Defines the value field of the Kafka message.
      3. Add Stream Property: Allows adding additional stream configurations.\
         Sample Example to create a stream:<br>

         ```
         CREATE STREAM orders_stream (
          order_id INT,
          customer STRING,
          amount DOUBLE
         )
         WITH (
          KAFKA_TOPIC='orders',
          VALUE_FORMAT='JSON'
         );
         ```
   3. **Buttons:**
      1. Clear: Clears the query editor content.
      2. Execute: Runs the KSQL query.
      3. Execute KSQL Request: Executes the written KSQL request.<br>

         ![](https://1499573743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6jSyTKzD9UG0uYLYFS7I%2Fuploads%2Fgit-blob-3fa53fa17b7facda3d4c9c6261e73c1f42ce1172%2Funknown%20\(136\).png?alt=media)

#### **KSQL DB Query Execution to continuously read events**

Users can execute KSQL queries to fetch and process real-time Kafka stream data.

The following Steps are

Step 1 - Enter the KSQL query in the editor.

Step 2 - Click the Execute button to run the query.

Step 3 - View the schema and real-time results below.

Sample Example:

```
SELECT * FROM orders_stream EMIT CHANGES;
```

<figure><img src="https://1499573743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6jSyTKzD9UG0uYLYFS7I%2Fuploads%2Fgit-blob-f0f41b4e00128fdbe76cb4a4137f52e6b646bc90%2Fimage%20(26).png?alt=media" alt=""><figcaption></figcaption></figure>

*After executing the data, verify on the Schema console of KSQL that the real-time data stream is being produced.*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.livestreamiq.com/readme/3.-guide-to-navigation/3.4-cluster-overview/3.4.6-ksql-db.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
