Re: keeping 3 tables in sync w/ each other

From: btober(at)ct(dot)metrocast(dot)net
To:
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: keeping 3 tables in sync w/ each other
Date: 2007-09-18 12:37:09
Message-ID: 46EFC675.60706@ct.metrocast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ow Mun Heng wrote:
> Hi,
>
> I have 3 tables
>
> foo
> foo_loading_source1
> foo_loading_source2
>
> which is something like
>
> create table foo (a int, b int, c int)
> create table foo_loading_source1 (a int, b int, c int)
> create table foo_loading_source2 (a int, b int, c int)
>
> Is there a way which can be made easier to keep these 3 tables DDL in
> sync?
>
> the loading_sourceX tables are just a temporary-in-transit table for
> data \copy'ied into the DB before being inserted into the main foo
> table.
>
>

Since these are temporary tables, why don't you just create them on the
fly as temporary tables?

CREATE TEMPORARY TABLE foo_loading_source1 (LIKE foo);

CREATE TEMPORARY TABLE foo_loading_source2 (LIKE foo);

Then do your loading process. Then you don't really have to worry about
maintaining the loading tables at all.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2007-09-18 12:42:09 New PostgreSQL RPM sets are available for Fedora / RHEL
Previous Message John D. Burger 2007-09-18 12:24:55 Re: Q:Aggregrating Weekly Production Data. How do you do it?