Re: [GENERAL] Move rows from one database to other - Mailing list pgsql-general

From Francisco Olarte
Subject Re: [GENERAL] Move rows from one database to other
Date
Msg-id CA+bJJbwpuN7qwyWAgn7C+Ry27M+=DdoK4HETB8jtxx4=Vki-6g@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Move rows from one database to other  (Thomas Güttler <guettliml@thomas-guettler.de>)
List pgsql-general
Thomas:

On Thu, Feb 23, 2017 at 4:26 PM, Thomas Güttler
<guettliml@thomas-guettler.de> wrote:
> Am 23.02.2017 um 13:44 schrieb Leknín Řepánek:
>> Maybe you can do something like
>> WITH cte AS (
>> DELETE FROM t1 WHERE cond
>> RETURNINIG *
>> )
>> INSERT into t2
>> SELECT * FROM cte;
>>
>> To move rows between tables with combination with fdw_postgres and
>> foreign table.

> ... this way you don't need the second table ... nice.

If you do this WITH a FDW be careful with the semantics, as I think
you have several commits.

If the local ( t1 ) is commited before the remote, you can lose rows.

If the remote ( t2 ) is commited before the local you'll have dupes,
so you need some way to purge them.

These things can be solved with the aid of transaction manager, and
prepared transactions, but I'm not sure of the status of it in your
versions, and those things are difficult.

Francisco Olarte.


pgsql-general by date:

Previous
From: Francisco Olarte
Date:
Subject: Re: [GENERAL] Move rows from one database to other
Next
From: Francisco Olarte
Date:
Subject: Re: [GENERAL] Move rows from one database to other