Primero, cargue las tablas en dos esquemas separados en la misma base de datos.
CREATE SCHEMA db1;
CREATE TABLE db1.table1 (id INT PRIMARY KEY, value VARCHAR(10));
-- load the contents of Table1 @ Database1 into db1.table1
CREATE SCHEMA db2;
CREATE TABLE db2.table1 (id INT PRIMARY KEY, value VARCHAR(10));
-- load the contents of Table1 @ Database2 into db2.table1
Luego puede fusionar los dos, dando prioridad a db2 sobre db1.
SELECT
DISTINCT ON (id)
id,
value
FROM (
SELECT
*,
1 AS db
FROM
db1.table1
UNION
SELECT
*,
2 AS db
FROM
db2.table1) AS mix
ORDER BY
id,
db DESC;