Skip to content
Last updated

Querying a Knowledge Base

After you create a knowledge base for your AI project, you'll want to do some quick queries to ensure you have the expected data.

Query Simulation

This topic includes:

You can check the setup of your Knowledge Bases by selecting the Details tab

To simulate a Knowledge Base, select the Test tab.

List Columns Simulation Examples

List Columns

Enter table names

Search Schema Simulation Examples

Enter keywords to search

Query Data Directly Simulation Examples

Enter a SQL statement to run

Understanding Query Result Formats

Database knowledge bases support two result formats: Markdown-KV and JSON. The format you selected when creating the knowledge base determines how query results are displayed in the Test tab.

Markdown-KV Format

When you select Markdown-KV as the Format Type, query results are returned in a structured, human-readable format with headings and key-value pairs.

List Columns example:

List Columns result in Markdown-KV format

The result shows database and table information with column details in a structured format:

# Database "retail_demo"
## Table "customer_profiles"
### Column 1
name: customer_id
type: varchar
comment:
### Column 2
name: first_name
type: varchar
comment:

Query data directly example:

Query result in Markdown-KV format

For example, running this query:

SELECT customer_id, first_name, last_name, city, state 
FROM customer_profiles 
LIMIT 1

Returns results in this format:

# Records
## Record 1
customer_id: CUST-00613
first_name: Aiden
last_name: Hernandez
city: San Diego
state: CA

Truncation warning:

When query results exceed the Max rows limit, a warning message is automatically appended to help the AI agent recognize that results are incomplete:

Truncation warning in Markdown-KV format

For example, when Max rows is set to 2 but the query attempts to retrieve more records, the following warning appears:

# Warning
[TRUNCATED] Results limited to 2 rows. To retrieve more data, add pagination 
to your SQL query using OFFSET N LIMIT M (OFFSET must come before LIMIT), 
or add WHERE conditions to narrow the results.

This warning prompts the AI agent to refine the query with pagination or additional filtering conditions.

JSON Format

When you select JSON as the Format Type, query results are returned in traditional JSON format, similar to previous versions of the knowledge base feature.

Key Differences

FeatureMarkdown-KVJSON
Result readabilityHigh - structured headings with key-value pairsModerate - standard JSON arrays
Truncation awarenessAgent receives explicit warning when results are cut offNo explicit warning
Table filteringNot available - all database tables includedAvailable via Table configuration
Max rows / Timeout settingsFully supportedLimited or ignored

Next Step

Creating an Agent