ATTACH 'dbname=postgres user=postgres host=localhost' AS pg_db (TYPE postgres);
CREATE TABLE pg_db.new_table AS SELECT * FROM duckdb_table;
postgresql scanner
use to import and export data between duckdb and postgresql
-- Install and load the PostgreSQL scanner extension INSTALL postgres_scanner; LOAD postgres_scanner;
-- Attach the PostgreSQL database CALL postgres_attach('dbname=postgres user=postgres host=localhost');
-- Query data from PostgreSQL and copy to DuckDB CREATE TABLE duckdb_new_table AS SELECT * FROM postgres_scan('dbname=postgres user=postgres host=localhost', 'public', 'pg_table');
-- Copy data from DuckDB to PostgreSQL COPY pg_db.new_table FROM duckdb_new_table;