The DuckDB CLI is a command-line tool for interacting with DuckDB databases. It provides an interactive shell for executing SQL queries and managing databases.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/duckdb/duckdb/llms.txt
Use this file to discover all available pages before exploring further.
Starting the CLI
Basic Usage
Start the CLI with an in-memory database:Command-Line Options
The CLI supports various options to control its behavior:-c COMMAND- Run command and exit-cmd COMMAND- Run command before reading stdin-f FILENAME- Read and execute SQL from file-init FILENAME- Read initialization commands from file-readonly- Open database in read-only mode-version- Show DuckDB version
Interactive Mode
When started without the-c flag, DuckDB enters interactive mode:
Basic Query Examples
Create a table:Reading from Files
Execute SQL from a file:.read command in interactive mode:
Output Modes
The CLI supports multiple output formats. Change the output mode using the.mode command:
duckbox- Unicode box drawing (default)csv- Comma-separated valuesjson- JSON arraymarkdown- Markdown tabletable- ASCII tableline- One value per linelist- Values delimited by|
Exiting the CLI
Exit the CLI using:Ctrl+D (Unix/Linux/macOS) or Ctrl+Z then Enter (Windows).