duckdb for Debian ----------------- 1. Create a CSV file: duckdb -c "COPY (SELECT 'Alice' AS name, 30 AS age UNION ALL SELECT 'Bob', 25) TO 'people.csv' (HEADER)" 2. Create a Parquet file: duckdb -c "COPY (SELECT 'Alice' AS name, 30 AS age UNION ALL SELECT 'Bob', 25) TO 'people.parquet'" 3. Query a CSV file directly (no import needed): duckdb -c "SELECT * FROM 'people.csv'" 4. Run a query against the CSV file: duckdb -c "SELECT name FROM 'people.csv' WHERE age > 27" 5. Query a Parquet file directly: duckdb -c "SELECT * FROM 'people.parquet'" 6. Import a CSV into a persistent table: duckdb mydata.db -c "CREATE TABLE people AS SELECT * FROM 'people.csv'" 7. Query the imported table: duckdb mydata.db -c "SELECT * FROM people" 8. List the largest installed packages on this system: echo 'package,version,size_KiB' > packages.csv dpkg-query -W -f '${Package},${Version},${Installed-Size}\n' >> packages.csv duckdb -c "SELECT package, version, size_KiB FROM read_csv('packages.csv', header=true) ORDER BY size_KiB DESC LIMIT 20" Extensions compiled into libduckdb.so -------------------------------------- json, icu and autocomplete are compiled directly into libduckdb.so. They need no INSTALL or LOAD from disk — they are already part of the library. 9. json — read and write JSON files directly: duckdb -c "COPY (SELECT 'Alice' AS name, 30 AS age UNION ALL SELECT 'Bob', 25) TO 'people.json'" duckdb -c "SELECT * FROM 'people.json'" 10. icu — timezone-aware timestamp handling: duckdb -c "SELECT TIMESTAMPTZ '2026-01-15 09:15:00 UTC' AT TIME ZONE 'America/New_York' AS ny_time" 11. autocomplete — suggest SQL completions for a partial query (also powers Tab-completion in the interactive shell): duckdb -c "SELECT * FROM sql_auto_complete('SELECT * FROM my_ta')" Extensions bundled with this package ------------------------------------- httpfs, quack, sqlite_scanner, postgres_scanner and mysql_scanner are built from source and shipped as loadable files in /usr/lib/duckdb/extensions/. None of these need INSTALL, and LOADing them never touches the network — they are already on disk. 12. httpfs — query remote files over HTTP/S directly without downloading them. This example queries the NYC taxi dataset hosted as a Parquet file: duckdb -c "LOAD httpfs; SELECT passenger_count, round(avg(fare_amount), 2) AS avg_fare FROM 'https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2024-01.parquet' GROUP BY passenger_count ORDER BY passenger_count LIMIT 5" 13. quack — server/client protocol. quack_serve() returns as soon as the listener is up, so start the server with -cmd (not -c): it drops to a prompt instead of exiting, which keeps the listener alive. Leave that terminal open and run the client in a second terminal. Server: duckdb -cmd "LOAD httpfs; LOAD quack; CREATE TABLE hello AS FROM VALUES ('world') v(s); CALL quack_serve('quack:localhost', token => 'secret');" Client: duckdb -c "LOAD quack; ATTACH 'quack:localhost' AS remote (TYPE quack, TOKEN 'secret', DISABLE_SSL true); FROM remote.hello;" 14. sqlite_scanner — read and write SQLite database files directly: duckdb -c "LOAD sqlite_scanner; ATTACH 'people.sqlite3' AS sq (TYPE sqlite); CREATE TABLE sq.people AS SELECT 'Alice' AS name, 30 AS age; SELECT * FROM sq.people" 15. postgres_scanner — attach to a PostgreSQL database and query it like a native table. Requires a running, already-configured PostgreSQL server: duckdb -c "LOAD postgres_scanner; ATTACH 'dbname=mydb' AS pg (TYPE postgres); SELECT * FROM pg.public.mytable LIMIT 5" 16. mysql_scanner — attach to a MySQL/MariaDB database and query it like a native table. Requires a running, already-configured MySQL/MariaDB server: duckdb -c "LOAD mysql_scanner; ATTACH 'host=localhost user=myuser database=mydb' AS my (TYPE mysql); SELECT * FROM my.mydb.mytable LIMIT 5" Downloadable extensions (amd64 and arm64 only) ----------------------------------------------- Pre-built extensions are not available for loong64, ppc64el and riscv64; examples 17-18 below will fail on those architectures. DuckDB has a built-in registry of known extensions compiled into the binary. To list all available extensions and their status: duckdb -c "SELECT extension_name, installed, loaded, install_mode, description FROM duckdb_extensions()" External extensions are downloaded from extensions.duckdb.org and installed into ~/.duckdb/extensions///. The binary knows which extensions exist and where to fetch them — no network access is needed just to list them. Each extension is installed once with INSTALL, then loaded with LOAD at the start of each session. 17. inet — adds IP address types (INET/CIDR) and network functions. This example reads all network interfaces and their addresses from the system, including interfaces that are down: duckdb -c "INSTALL inet" ip -j a > /tmp/interfaces.json duckdb -c "LOAD inet; SELECT ifname, operstate, family, local::inet AS address FROM (SELECT ifname, operstate, unnest(addr_info, recursive:=true) FROM read_json('/tmp/interfaces.json')) UNION ALL SELECT ifname, operstate, NULL, NULL FROM read_json('/tmp/interfaces.json') WHERE len(addr_info) = 0 ORDER BY ifname" 18. spatial — geospatial types and functions (points, polygons, distance, etc.). This example calculates the distance in km from Paris to several European cities: duckdb -c "INSTALL spatial" duckdb -c "LOAD spatial; SET geometry_always_xy = true; SELECT city, ST_Point(lon, lat) AS location, round(ST_Distance_Sphere(ST_Point(lon, lat), ST_Point(2.3522, 48.8566)) / 1000, 0) AS km_from_paris FROM (VALUES ('Paris', 2.3522, 48.8566), ('Berlin', 13.4050, 52.5200), ('London', -0.1276, 51.5074), ('Madrid', -3.7038, 40.4168)) t(city, lon, lat) ORDER BY km_from_paris" For all command-line options: duckdb -h For shell dot commands: type .help inside the shell.