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

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

From
Intengu Technologies
Date:
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

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

From
Serge Fonville
Date:
Hi,

Both can do the job

Use a union

HTH

Regards,

Serge Fonville

On Mon, Sep 28, 2009 at 9:59 AM, Intengu Technologies <sindile.bidla@gmail.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@postgresql.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

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

From
Intengu Technologies
Date:
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.fonville@gmail.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.bidla@gmail.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@postgresql.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