Skip to content
KNIME Documentation
Main Navigation Get startedBuildWork with KnimeAccount and adminRelease notesDeveloper tools
Community Hub
DevelopersKnime
Sidebar Navigation

Getting Started

Installation

User Guide

Release Notes

Install Extensions

Building Workflows

Components

Flow Control

Expressions

File Handling

Deployment

Integrated Deployment

Workflow Invocation

Best Practices

Advanced Features

AI Extension

Get Started

Build an Agent

Inject context with RAG

LLM Providers

Tutorials

Summarize product reviews

Product FAQ assistant

Restaurant agent

Your first local agent

Task extractor

Reporting

Kerberos

Extensions

Database

Overview

Tutorials

Read and filter data from a database

Write a transformed dataset to a database

Concepts

Ports and Sessions

Query Generation

Type Mapping

Deprecated Framework

Connecting

Connect: Dedicated Node

Connect: File-Based Database

Connect: Generic DB Connector

Register a JDBC Driver

Install Third-Party Driver Plug-in

Drivers on Hub and Server

Kerberos Constrained Delegation

Reading and Transforming

Read Data

Transform Data Visually

Run a Custom SQL Query

Parameterize a Query

Writing and Modifying

Insert, Update, or Merge

Delete Rows

Bulk Load Data

Create and Remove Tables

Use Transactions

Reference

Connector Node Settings

JDBC Driver Reference

Deprecated Node Mapping

Migrate Deprecated Workflows

Python

Overview

Tutorials

Python Scripting Quickstart

Data App Development Using Plotly

Data Processing

K-AI Scripting Assistant

Data Type Conversion

Batch Processing

Jupyter Integration

Environment Management

Pixi Configuration

Dependency Management

Environment Persistence

Channel Mirrors & Air-Gapped Setups

Conda Migration

Alternative Configurations

Conda and Miniforge Setup

Conda Environment Propagation

Manual Python Configuration

Legacy Node Migration

Concepts

Pixi Backend Architecture

Storage Logic

Python Environments on Executors

Reference

Python Scripting API

Bundled Packages

Executor and Hub Configuration

Troubleshooting Guide

API Reference

Inputs and outputs

Classes

Views

Utility functions

R

Deep Learning

Snowflake

Google Cloud

Azure

AWS

Big Data

Big Data Admin

Big Data Secured Cluster

Databricks

Microsoft Fabric

Power BI

Tableau

Report Designer

H2O

Changelogs

Version 5.12

Version 5.11

Version 5.10

Version 5.9

Version 5.8

Version 5.7

Version 5.6

Version 5.5

Version 5.3

Extensions

Run a custom SQL query ​

Use the DB Query, DB Query Reader, or DB SQL Executor node when the visual DB nodes do not cover your use case and you need to write SQL directly.

Before you begin ​

  • Establish a database connection. See Connect to a database using a dedicated connector node or Connect to a database with the generic DB Connector.

Modify an incoming query with DB Query ​

The DB Query node modifies the SQL query from an incoming DB Data connection. Use it to wrap or extend the upstream query with additional SQL.

  1. Connect a DB Query node to a DB Data output port.
  2. Click the node once to open a compact SQL editor, then click the expand icon to open the full configuration.
  3. Write your SQL statement in the editor. The placeholder #table# represents the incoming query and is replaced with the upstream subquery at execution time.
  4. Click Evaluate to test the statement and preview the result under Output preview.
  5. Click Apply to save the configuration, or Apply and Execute to save it and run the node.

TIP

The Input tab lists the columns and flow variables available from the incoming connection. Switch to the Database tab to browse the database schema.

Execute a standalone SQL query with DB Query Reader ​

The DB Query Reader node executes a SQL statement and returns the result as a KNIME data table. It does not wrap the query in a subquery and accepts any statement that returns rows — including DESCRIBE TABLE and other non-SELECT statements.

  1. Connect a DB Query Reader node to a DB Connection output port.
  2. Click the node once to open a compact SQL editor, then click the expand icon to open the full configuration.
  3. Write your SQL statement in the editor.
  4. Click Evaluate to test the statement and preview the result under Output preview.
  5. Optionally, configure Type Mapping to override how database types map to KNIME types. See Type mapping.
  6. Click Apply to save the configuration, or Apply and Execute to save it and run the node.

TIP

Use DB Query Reader instead of chaining DB Query when your database does not support subqueries.

Execute a non-returning SQL statement with DB SQL Executor ​

Use the DB SQL Executor node to run SQL statements that do not return data, such as CREATE, DROP, or ALTER.

  1. Connect a DB SQL Executor node to a DB Connection output port.
  2. Click the node once to open the SQL editor and enter your SQL statement.
  3. Click Apply and Execute to save the configuration and run the node.

Next steps ​

  • Parameterize a SQL query
  • Transform data visually in a database

Related pages ​

  • Query generation
  • Read data from a database
Pager
Next pageInstallation