DuckDB: migrate data with multi-database support

DuckDB's multi-database-support can be a convenient way to transform and move data between databases.

For example, with the SQLite and MySQL extension:

ATTACH 'host=HOST port=0 database=DATABASE user=USER password=PASSWORD' AS src (TYPE mysql);

ATTACH 'mydb.sqlite3' AS dst (TYPE sqlite);

WITH import AS (
    SELECT
        t.somecolumn,
        o.othercolumn
        -- ...
    FROM src.mytable t
    INNER JOIN src.othertable o ON o.id = t.id
    WHERE ...
) INSERT INTO dst.postings (
    -- column1
    -- column2
    -- ...
) SELECT
    -- value1
    -- value2
    -- ...
FROM import;

Created 2024-03-24T11:59:45+01:00, updated 2024-03-26T21:27:41+01:00 · History · Edit