Re: Synchronize tables question....

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Synchronize tables question....
Дата
Msg-id 45D9AE96.90003@archonet.com
обсуждение исходный текст
Ответ на Synchronize tables question....  (Jerry LeVan <jerry.levan@eku.edu>)
Ответы Re: Synchronize tables question....  (Jerry LeVan <jerry.levan@eku.edu>)
Список pgsql-general
Don't forget to CC: the list

Jerry LeVan wrote:
>
>>> Is there an elegant way I can merge/update the two tables so that
>>> they will contain the same information ( with no duplicates or
>>> omissions)?
>>
>> It sounds like you'll want some form of replication, but whether
>> single-master or multi-master no-one can say without more information.

> I meant to say I had dblink installed :)
>
> The following sequence of steps seems to work ok, the tables are very
> small...

> insert into tmpRegistrations select *
>    from dblink('select * from registrations ')
>    as (software text,
>        id text,
>        value text,
>        location text
>       )
>
> select dblink_disconnect()
>
> create temp table newregistrations as
>    (select * from registrations union select * from tmpregistrations )
>
> truncate table registrations
>
> insert  into registrations  select * from newregistrations

A couple of points:
1. What if a registration is updated?
2. What happens if you get a new registration between CREATE TEMP TABLE
and TRUNCATE?

--
   Richard Huxton
   Archonet Ltd

В списке pgsql-general по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Small request re error message
Следующее
От: Jerry LeVan
Дата:
Сообщение: Re: Synchronize tables question....