Installing DuckDB
Before we start writing queries, we need to install DuckDB. According to the official DuckDB 2.0 documentation, the latest stable version is 2.0.0 (LTS). DuckDB is available on many platforms and programming languages.
Fastest Installation Method (CLI)
If you want to try DuckDB straight from the terminal, use the official install script:
curl https://install.duckdb.org | bash
This script detects your operating system and downloads the appropriate DuckDB CLI.
Installation by Platform
macOS
Download directly or use the install script:
curl https://install.duckdb.org | bash
Or via Homebrew:
brew install duckdb
The CLI file for macOS is available as duckdb-cli-osx-universal.tar.gz from install.duckdb.org.
Linux
curl https://install.duckdb.org | bash
Available for amd64 and arm64 architectures through direct downloads from install.duckdb.org/v2.0.0/.
Windows
Run the following command from the Run menu (Win+R) or Command Prompt:
powershell -NoExit -ExecutionPolicy Bypass -Command "irm https://install.duckdb.org/install.ps1 | iex"
Note: DuckDB on Windows requires Microsoft Visual C++ Redistributable.
Installation with Docker
If you use Docker, run the DuckDB CLI in a container:
docker run --rm -it -v "$(pwd):/workspace" -w /workspace duckdb/duckdb:2.0.0
This command mounts the current folder to /workspace inside the container, so the .duckdb database files you create will be saved on the host machine.
Installation for Programming Languages
DuckDB also has clients for various languages. Here are some common installation examples:
Python
pip install --upgrade duckdb
Node.js
npm install @duckdb/node-api
Go
go get github.com/duckdb/duckdb-go/v2
R
install.packages("duckdb")
Java (JDBC)
Add the dependency to pom.xml (Maven):
<dependency>
<groupId>org.duckdb</groupId>
<artifactId>duckdb_jdbc</artifactId>
<version>2.0.0.1</version>
</dependency>
Verifying the Installation
After installing the CLI, try running DuckDB in the terminal:
duckdb
If the installation was successful, you'll see the DuckDB prompt, like this:
v2.0.0
Enter ".help" for usage hints.
Connected to a transitory in-memory database.
Type .exit to leave the DuckDB prompt.
Summary
DuckDB 2.0 (LTS) is easy to install via the official script, a package manager, Docker, or a programming language library. Once installed, you're ready to run your first query.
In the next chapter, we'll run our first query and read a CSV file directly using the DuckDB CLI.