Database / DuckDB Interview questions
What is ATTACH used for in DuckDB?
ATTACH connects DuckDB to another database, either another DuckDB file or, via extensions, an entirely different database system like PostgreSQL, MySQL, or SQLite, making its tables directly queryable (and in some cases writable) from within the same DuckDB session.
ATTACH 'other_database.duckdb' AS other; SELECT * FROM other.my_table; ATTACH 'postgres://user:pass@localhost/mydb' AS pg (TYPE postgres); SELECT * FROM pg.customers JOIN main.local_orders ON ...;
This lets a single DuckDB session query and even join across data that physically lives in a running Postgres instance and data that lives locally, or across multiple separate DuckDB files, without needing an ETL step to first copy everything into one place. It's particularly useful for exploratory analysis that needs to combine an operational database's live data with local files or another analytical dataset in a single query.
More Related questions...