2023-08-11 11:35:01 +01:00
|
|
|
# duckdb
|
|
|
|
|
|
|
|
> Command-line client for DuckDB, an in-process analytical SQL engine.
|
|
|
|
> More information: <https://duckdb.org>.
|
|
|
|
|
|
|
|
- Start an interactive shell with a transient in-memory database:
|
|
|
|
|
|
|
|
`duckdb`
|
|
|
|
|
|
|
|
- Start an interactive shell on a database file. If the file does not exist, a new database is created:
|
|
|
|
|
|
|
|
`duckdb {{path/to/dbfile}}`
|
|
|
|
|
|
|
|
- Directly query a CSV, JSON, or Parquet file:
|
|
|
|
|
|
|
|
`duckdb -c "{{SELECT * FROM 'data_source.[csv|csv.gz|json|json.gz|parquet]'}}"`
|
|
|
|
|
2024-02-23 08:21:08 +00:00
|
|
|
- Run an SQL script:
|
2023-08-11 11:35:01 +01:00
|
|
|
|
|
|
|
`duckdb -c ".read {{path/to/script.sql}}"`
|
|
|
|
|
|
|
|
- Run query on database file and keep the interactive shell open:
|
|
|
|
|
|
|
|
`duckdb {{path/to/dbfile}} -cmd "{{SELECT DISTINCT * FROM tbl}}"`
|
|
|
|
|
|
|
|
- Run SQL queries in file on database and keep the interactive shell open:
|
|
|
|
|
|
|
|
`duckdb {{path/to/dbfile}} -init {{path/to/script.sql}}`
|
|
|
|
|
2023-10-24 02:25:09 +01:00
|
|
|
- Read CSV from `stdin` and write CSV to `stdout`:
|
2023-08-11 11:35:01 +01:00
|
|
|
|
2024-07-21 10:55:13 +01:00
|
|
|
`cat {{path/to/source.csv}} | duckdb -c "{{COPY (FROM read_csv('/dev/stdin')) TO '/dev/stdout' WITH (FORMAT CSV, HEADER)}}"`
|
2023-08-11 11:35:01 +01:00
|
|
|
|
|
|
|
- Display help:
|
|
|
|
|
|
|
|
`duckdb -help`
|