Monday, June 16, 2025

DuckLake ATTACH quick reference.

 Here are some examples I put together while exploring the DuckLake ATTACH command.

.bail on

.echo on


INSTALL ducklake; LOAD ducklake;

INSTALL httpfs;   LOAD httpfs;

INSTALL sqlite;   LOAD sqlite;

INSTALL postgres; LOAD postgres;

INSTALL mysql;   LOAD mysql;



--       ATTACHMENT      DATABASE    DATA PATH    DATABASE CREATION

--               x1   unspecified      default

--               x2        duckdb      default

--               x3        sqlite   local file

--               x4        duckdb          gcs

--               x5      postgres          gcs    createdb x5_catalog

--               x6         mysql          gcs    mysqladmin -u root -p create x6_catalog


ATTACH 'ducklake:x1.ducklake'                   AS x1;

ATTACH 'ducklake:duckdb:x2.ducklake'            AS x2;

ATTACH 'ducklake:sqlite:x3.sqlite'              AS x3 (DATA_PATH 'x3.ducklake.files/');

ATTACH 'ducklake:duckdb:x4.ducklake'            AS x4 (DATA_PATH 'gs://marhar-scratch/x4.ducklake.files/');

ATTACH 'ducklake:postgres:dbname=x5_catalog'    AS x5 (DATA_PATH 'gs://marhar-scratch/x5.ducklake.files/');

ATTACH 'ducklake:mysql:db=x6_catalog user=root' AS x6 (DATA_PATH 'gs://marhar-scratch/x6.ducklake.files/');

ATTACH 'ducklake:postgres:dbname=x7_catalog'    AS x7 (DATA_PATH 's3://marhar-scratch/x7.ducklake.files/');  


CREATE TABLE IF NOT EXISTS x1.t1 (a int, b int);

CREATE TABLE IF NOT EXISTS x2.t1 (a int, b int);

CREATE TABLE IF NOT EXISTS x3.t1 (a int, b int);

CREATE TABLE IF NOT EXISTS x4.t1 (a int, b int);

CREATE TABLE IF NOT EXISTS x5.t1 (a int, b int);

CREATE TABLE IF NOT EXISTS x6.t1 (a int, b int);

CREATE TABLE IF NOT EXISTS x7.t1 (a int, b int);  


INSERT INTO x1.t1 VALUES (1, 2), (3, 4);

INSERT INTO x2.t1 VALUES (5, 6), (7, 8);

INSERT INTO x3.t1 VALUES (9, 10), (11, 12);

INSERT INTO x4.t1 VALUES (13, 14), (15, 16);

INSERT INTO x5.t1 VALUES (13, 14), (15, 16);

INSERT INTO x6.t1 VALUES (13, 14), (15, 16);

INSERT INTO x7.t1 VALUES (13, 14), (15, 16);  


DuckLake ATTACH quick reference.

 Here are some examples I put together while exploring the DuckLake ATTACH command. .bail on .echo on INSTALL ducklake; LOAD ducklake; INSTA...