Skip site navigation (1) Skip section navigation (2)

Re: How do I create a new table based on combining a number of tables

From: Intengu Technologies <sindile(dot)bidla(at)gmail(dot)com>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: How do I create a new table based on combining a number of tables
Date: 2009-09-28 10:00:37
Message-ID: a1afa64b0909280300i5e84a392p827f9d8a63bd3ed4@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
Thanks Serge

Here is my attempt of an sql statement, but only the first table is
being inserted.

As a nice to have would also to add a field to indicate from which table.

1. create table allfrm_1

2. insert the records of the other tables into allfrm_1

INSERT INTO deeds.allfrm_1

SELECT * FROM  deeds.plssblmfrm_1
UNION ALL

SELECT * FROM  deeds.plssctnfrm_1
UNION ALL

SELECT * FROM  deeds.plssjhbfrm_1
UNION ALL

SELECT * FROM  deeds.plsskimfrm_1
UNION ALL

SELECT * FROM  deeds.plsskwtfrm_1
UNION ALL

SELECT * FROM  deeds.plsspmbfrm_1
UNION ALL

SELECT * FROM  deeds.plssptafrm_1
UNION ALL

SELECT * FROM  deeds.plssutafrm_1
UNION ALL

SELECT * FROM  deeds.plssvryfrm_1
;

2009/9/28 Serge Fonville <serge(dot)fonville(at)gmail(dot)com>:
> Hi,
> Both can do the job
> Use a union
> http://www.postgresql.org/docs/8.4/interactive/queries-union.html.
> HTH
> Regards,
> Serge Fonville
>
> On Mon, Sep 28, 2009 at 9:59 AM, Intengu Technologies
> <sindile(dot)bidla(at)gmail(dot)com> wrote:
>>
>> Hi List
>>
>> I have a number of tables that I would want to combine (append one
>> table to another) into a single table. What would be the best approach
>> and how do I write the corresponding sql statement:
>>
>> 1. Create a new table
>>
>> 2. Create a view
>>
>> --
>> Sindile Bidla
>>
>> --
>> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-novice
>
>
>
> --
> Convince Google!!
> They need to support Adsense over SSL
> https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=10528
> http://www.google.com/support/forum/p/AdSense/thread?tid=1884bc9310d9f923&hl=en
>



-- 
Sindile Bidla

In response to

pgsql-novice by date

Next:From: Ounce SnowDate: 2009-09-30 11:57:27
Subject: error message on install
Previous:From: Serge FonvilleDate: 2009-09-28 08:04:10
Subject: Re: How do I create a new table based on combining a number of tables

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group