> For the complete documentation index, see [llms.txt](https://ztrust.gitbook.io/livestreamiq/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ztrust.gitbook.io/livestreamiq/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.&#x20;

<figure><img src="/files/JEZeH7uvzLxRvFWOdRLk" 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>

   ![](/files/8vrXUCFW1GDXDlbZ5986)

   1. **KSQL Editor:**      &#x20;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'
         );
         ```

         &#x20;
   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>

         ![](/files/nJ6MmK5rTWG5ECUYQJdq)

#### **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="/files/tHlspzneCXY98cBY75VT" alt=""><figcaption></figcaption></figure>

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