continuous copy/update one table to another

From: Terry <td3201(at)gmail(dot)com>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: continuous copy/update one table to another
Date: 2010-02-28 21:56:41
Message-ID: 8ee061011002281356t5239db2qaf10a225dce60e97@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I am looking for a way to copy all the data from one table to another
on a regular basis, every 5 minutes let's say.

INSERT INTO table2 SELECT * FROM table1;

The above will copy all the data as is and insert it into the other
table. What happens if I rerun it again? Will it just append table1
again into table2? How can I have it only insert rows that are
different? Would that be a program to lookup the most last record in
table 1 and then a query to only select after that row for the insert
into table2?

Thanks!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David W Noon 2010-02-28 22:31:57 Re: continuous copy/update one table to another
Previous Message Tom Lane 2010-02-28 20:01:14 Re: Partial foreign keys