DuckDB
The DuckDB Altertable extension connects DuckDB to Altertable over Arrow Flight SQL. Use it when you want to query governed Altertable data from DuckDB, join it with local files, or write results back to attached Altertable tables.
The extension supports:
- Attached databases for querying Altertable catalogs with standard SQL
- Direct table access through DuckDB's catalog
- Raw query execution for remote SQL statements
- Attached writes with
CREATE TABLE,CREATE TABLE AS, andINSERT
Installation
Install and load the community extension from DuckDB:
INSTALL altertable FROM community;LOAD altertable;
Attach a database
Use your Altertable username, password, and catalog in the connection string:
ATTACH 'user=my-user password=my-pass catalog=my-altertable-catalog' AS analytics (TYPE ALTERTABLE);SELECT * FROM analytics.main.orders;
Connection parameters
Parameter | Description | Example |
|---|---|---|
user | Altertable username | your-altertable-user |
password | Altertable password | your-altertable-password |
catalog | Remote Altertable catalog | analytics |
Secrets
Or use DuckDB secrets:
CREATE SECRET my_altertable (TYPE altertable,USER 'your-user',PASSWORD 'your-password',CATALOG 'your-altertable-catalog');ATTACH '' AS analytics (TYPE altertable, SECRET my_altertable);
Detach a database
DETACH analytics;
Query and update remote tables
Run SELECT queries against attached Altertable tables:
SELECT order_id, amount, statusFROM remote_db.main.ordersWHERE status = 'open';
Create remote tables through the attached database:
CREATE TABLE remote_db.main.new_orders (order_id INTEGER,amount DOUBLE,status VARCHAR);
or from a local databases:
CREATE TABLE remote_db.main.new_orders AS SELECT * FROM local_db.main.orders;
Update table definitions:
ALTER TABLE remote_db.main.new_orders ADD COLUMN note VARCHAR;
Export table to a local file:
COPY remote_db.main.orders TO 'orders.csv';COPY remote_db.main.orders TO 'orders.parquet';COPY remote_db.main.orders TO 'orders.json';
For more examples and source builds, see the DuckDB Altertable extension repository.