PROMPT_EXPLAIN
Explain a query
The prompt_explain
table function allows MotherDuck AI to analyze and explain SQL queries in plain English. This feature helps you understand complex queries, verify that a query does what you intend, and learn SQL concepts through practical examples.
tip
This function is particularly useful for understanding queries written by others or for automatically documenting your own queries for future reference.
Syntax
CALL prompt_explain('<SQL query>', [include_tables=['<table_name>', '<table_name>']]);
Parameters
Parameter | Required | Description |
---|---|---|
query | Yes | The SQL query to explain |
include_tables | No | Array of table names to consider for context (defaults to all tables in current database). Can also be a dictionary in the format {'table_name': ['column1', 'column2']} to specify which columns to include for each table. |
Example usage
Here are several examples using MotherDuck's sample Hacker News dataset from MotherDuck's sample data database.