Skip to main content
SQL tools support configurable output formatting to optimize readability and control the display of query results. Configure table styles, row limits, and output formats to match your use case.
Output formatting options only apply when responseFormat: markdown is set. Tools using responseFormat: json return raw JSON data without formatting.

Overview

The output formatting system provides:
  • Multiple table styles for different display contexts
  • Type-aware column alignment (numeric right-aligned, text left-aligned)
  • NULL value handling with configurable replacements
  • Row truncation with clear truncation indicators
  • Metadata display including execution time, row counts, and NULL statistics

Configuration Options

Output formatting is configured using optional fields in the tool definition:
The tableFormat and maxDisplayRows fields are optional. If omitted, the tool uses default values.

Table Format Styles

Four table styles are available to suit different display contexts:

1. markdown (Default)

GitHub-flavored markdown table format with column type indicators. Best for documentation, web viewers, and LLM consumption. Characteristics:
  • Uses | for column separators
  • Includes --- header separator with alignment indicators
  • Column headers include type information: EMPLOYEE_ID (INTEGER)
  • Numeric columns automatically right-aligned
  • Most readable in markdown renderers
Example:
Use Cases:
  • Default choice for most tools
  • Documentation and reports
  • Web-based interfaces
  • LLM-friendly output

2. ascii

Plain ASCII table format using +, -, and | characters. Compatible with any text display. Characteristics:
  • Uses + for corners and intersections
  • Uses - for horizontal borders
  • Uses | for vertical borders
  • Works in any text editor or terminal
  • Fixed-width display for consistent alignment
Example:
Use Cases:
  • Plain text environments
  • Email or text file output
  • Legacy system integration
  • Terminal-based tools

3. grid

Unicode box-drawing characters for a polished, professional appearance. Characteristics:
  • Uses Unicode box-drawing characters (, , , , , , , , )
  • Visually distinct and modern
  • Requires Unicode support
  • Slightly more compact than ASCII
Example:
Use Cases:
  • Modern terminal output
  • Professional reports
  • Rich text environments
  • Visual clarity over compatibility

4. compact

Minimal spacing for space-constrained displays. Characteristics:
  • Reduced column padding (1 space instead of 2)
  • Still uses markdown-style separators
  • Maintains alignment and readability
  • Most space-efficient option
Example:
Use Cases:
  • Mobile or narrow displays
  • High-density information display
  • Logs with space constraints
  • Minimalist output preferences

Maximum Display Rows

The maxDisplayRows field controls how many rows are displayed before truncation occurs.
Display vs. fetch: maxDisplayRows only truncates the rendered table — the server still fetched those rows from the database. To change how many rows are pulled from Db2 for i, see fetch-row controls in the Tools Reference.

Configuration

Constraints:
  • Minimum: 1
  • Maximum: 1000
  • Default: 100
Behavior:
  • If result row count ≤ maxDisplayRows: All rows are displayed
  • If result row count > maxDisplayRows: First maxDisplayRows rows shown with truncation alert

Truncation Alert

When truncation occurs, a clear alert message is displayed:

Use Cases for Different Limits


Configuration Examples

Example 1: Default Configuration

Most tools work well with defaults (markdown format, 100-row limit):

Example 2: ASCII Format

Use for: Plain text files, emails, legacy terminals, non-Unicode systems

Example 3: Grid Format

Use for: Professional reports, dashboards, modern terminals

Example 4: Compact Format

Use for: Space-constrained displays, logs, high-density data

Example 5: High Row Limit

Use for: Data exports, comprehensive analysis, admin tools

Automatic Features

Column Type Awareness

Columns are automatically aligned based on database types:
  • Right-aligned: INTEGER, DECIMAL, FLOAT, NUMERIC (all numeric types)
  • Left-aligned: VARCHAR, CHAR, DATE, TIME, TIMESTAMP (text and temporal types)
Column headers include type information: SALARY (DECIMAL) Example Output:

NULL Value Handling

  • NULL values display as - (dash)
  • NULL counts tracked per column in metadata
  • Consistent across all table formats
Example Output with NULLs:

Complete Output Structure

A fully-formatted SQL tool response includes:
  1. Tool Name Header (H2)
  2. Success Alert with checkmark
  3. Result Table with type-aware formatting
  4. Truncation Alert (if applicable)
  5. Metadata Section with:
    • Execution time
    • Row counts (displayed and total)
    • NULL value statistics
    • Parameter values used
  6. Performance Metrics (optional)

Example Complete Output


Best Practices

Format Selection

Choose the right format for your context:
Use for:
  • LLM consumption (default)
  • Web-based UIs
  • Documentation
  • Markdown renderers
Characteristics:
  • Most readable
  • Type annotations
  • Alignment indicators

Row Limits by Use Case

Performance Considerations

Lower Row Limits

  • Faster response times
  • Reduced network transfer
  • Better for interactive use
  • Combine with SQL LIMIT

SQL Optimization

  • Use SQL LIMIT clauses at database level
  • Add ORDER BY for most relevant rows first
  • Consider pagination for large datasets
  • Index columns used in ORDER BY

Combining with SQL

Best practice: Use both SQL-level and display-level limits:
Benefits:
  • Database does less work (FETCH FIRST)
  • Network transfers less data
  • Display limit acts as safety net
  • Consistent results across reruns

Comparison: All Table Styles


Next Steps

Parameters

Learn about parameter types and constraints

Validation

Understand parameter validation

Building Tools

Step-by-step tool creation guide

SQL Tools Overview

Introduction to the SQL tools system