2 Getting started with DuckDB

 

This chapter covers

  • Installing and learning how to use the DuckDB command-line interface
  • Executing commands in the DuckDB CLI
  • Querying remote files

Now that we have an understanding of what DuckDB is and why it came into prominence in the early 2020s, it’s time to get familiar with it. This chapter will be centered on the DuckDB command-line interface (CLI). We’ll learn how to install it on various environments, before learning about the its built-in commands. We’ll conclude by querying a remote CSV file.

2.1 Supported environments

DuckDB is available for a range of different programming languages and operating systems (Linux, Windows, and macOS) both for Intel/AMD and ARM architectures. At the time of writing, there is support for the command line, Python, R, Java, JavaScript, Go, Rust, Node.js, Julia, C/C++, ODBC, JDBC, WASM, and Swift. In this chapter, we will focus on the DuckDB command line exclusively, as we think that is the easiest way to get you up to speed. The DuckDB CLI does not require a separate server installation, as DuckDB is an embedded database, and in the case of the CLI, it is embedded in the CLI executable.

The command-line tool is published to GitHub releases, and there are a variety of packages for different operating systems and architectures. You can find the full list on the installation page: https://duckdb.org/docs/installation/index.

2.2 Installing the DuckDB CLI

2.2.1 macOS

2.2.2 Linux and Windows

2.3 Using the DuckDB CLI

2.3.1 SQL statements

2.3.2 Dot commands

2.3.3 CLI arguments

2.4 DuckDB’s extension system

2.5 Analyzing a CSV file with the DuckDB CLI

2.5.1 Result modes

Summary