1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-16 23:15:25 +02:00
tldr/pages/common/duckdb.md

37 lines
1 KiB
Markdown
Raw Normal View History

2023-08-11 12:35:01 +02:00
# duckdb
> Client for DuckDB, an in-process analytical SQL engine.
2023-08-11 12:35:01 +02:00
> 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}}`
- Query a CSV, JSON, or Parquet file using SQL:
2023-08-11 12:35:01 +02:00
`duckdb -c "{{SELECT * FROM 'data_source.[csv|csv.gz|json|json.gz|parquet]'}}"`
- Directly query a CSV, JSON, or Parquet file using the `file` view:
`duckdb {{data_source.[csv|csv.gz|json|json.gz|parquet]}} -c "{{ SELECT * FROM file }}"`
- Run an SQL script:
2023-08-11 12:35:01 +02:00
`duckdb -f {{path/to/script.sql}}`
2023-08-11 12:35:01 +02:00
- Run query on database file and keep the interactive shell open:
`duckdb {{path/to/dbfile}} -cmd "{{SELECT DISTINCT * FROM tbl}}"`
- Read CSV from `stdin` and write CSV to `stdout`:
2023-08-11 12:35:01 +02:00
`cat {{path/to/source.csv}} | duckdb -c "{{COPY (FROM read_csv('/dev/stdin')) TO '/dev/stdout' WITH (FORMAT CSV, HEADER)}}"`
2023-08-11 12:35:01 +02:00
2025-04-20 12:13:20 +02:00
- Start the DuckDB UI, a web interface with notebooks:
2023-08-11 12:35:01 +02:00
2025-04-20 12:13:20 +02:00
`duckdb -ui`