I have to copy data from two databases to a new one, it happens that when you copied new data these already exist but there are new ones that are not inserted.
The query I have at the moment is this:
INSERT INTO concelho(id,censo,concelho)
SELECT "CONCELHO","CENSO","CONCELHO_DSG"
FROM dblink('dbname=meu_db host=meu_host user=meu_user password=minha_senha' ::text,'SELECT "CONCELHO","CENSO","CONCELHO_DSG" FROM "MUNICIPIO (Concelho)"' ::text,false)
as tabela_temp("CONCELHO" varchar, "CENSO" varchar, "CONCELHO_DSG" character varying (200))