# 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:

* [List Columns Simulation Examples](/products/customer-data-platform/ai-agent-foundry/knowledgebase/querying-a-knowledge-base#list-columns-simulation-examples)
* [Search Schema Simulation Examples](/products/customer-data-platform/ai-agent-foundry/knowledgebase/querying-a-knowledge-base#search-schema-simulation-examples)
* [Query Data Directly Simulation Examples](/products/customer-data-platform/ai-agent-foundry/knowledgebase/querying-a-knowledge-base#query-data-directly-simulation-examples)


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

![](/assets/knowledge-base-details.be1fce016409455ffc3f131bbd59a7d5cdd05aeb31b3e8d1818833d57d059bcf.91c26685.png)

To simulate a Knowledge Base, select the **Test** tab.

![](/assets/knowledge-base-test-tab.cbf883cee5ed1d5ff9f75d29497aa9c51cf56ec31981646440cc40d470a8b8e2.91c26685.png)

### List Columns Simulation Examples

List Columns

Enter table names

![](/assets/knowledge-base-list-columns.3813686296fca15161765ff28c170a76565b4443c27ce62e0684653d44d9e220.91c26685.png)

### Search Schema Simulation Examples

Enter keywords to search

![](/assets/knowledge-base-search-schema.14fb0c19c2af235561532a9f98b884d5183eaa218e363f73c08d63d1dfc69073.91c26685.png)

### Query Data Directly Simulation Examples

Enter a SQL statement to run

![](/assets/knowledge-base-query-data.949ac83a5176da23e5f6815daeef12dd040cd9eb72880be49aeacded115dbbd0.91c26685.png)

## 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](/assets/knowledge-base-markdown-kv-list-columns.7bbfd81bd2cf34e5f04c824e7e20d15824363dec5374ef765c9db38057db3cd4.91c26685.png)

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


```markdown
# 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](/assets/knowledge-base-markdown-kv-query-result.95cbbf9b4aead7c2b715eb070660805e584a79c30e656d34c71d933a93a1a313.91c26685.png)

For example, running this query:


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

Returns results in this format:


```markdown
# 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](/assets/knowledge-base-markdown-kv-truncation-warning.df1c07dd7980ba9dd60c59de4a87b6877c87a4bf5410e602d2fc65da2f8029e4.91c26685.png)

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


```markdown
# 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

| Feature | Markdown-KV | JSON |
|  --- | --- | --- |
| Result readability | High - structured headings with key-value pairs | Moderate - standard JSON arrays |
| Truncation awareness | Agent receives explicit warning when results are cut off | No explicit warning |
| Table filtering | Not available - all database tables included | Available via Table configuration |
| Max rows / Timeout settings | Fully supported | Limited or ignored |


**Next Step**

[Creating an Agent](/products/customer-data-platform/ai-agent-foundry/ai-agent/creating-an-agent)