Select into

Поиск
Список
Период
Сортировка
Искать

Select into

От:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
Дата:
Hi All,

Is it possible to insert into a table based on a select from another table?

The docs for SELECT INTO and like seem to imply you can only create a table
based on a select, not append to an existing table.

How do you do this?

Chris


Re: Select into

От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:

On Thu, 6 Dec 2001, Christopher Kings-Lynne wrote:

> Hi All,
>
> Is it possible to insert into a table based on a select from another table?
>
> The docs for SELECT INTO and like seem to imply you can only create a table
> based on a select, not append to an existing table.
>
> How do you do this?

I think you can use
INSERT INTO () SELECT ...



Re: Select into

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> Hi All,
> 
> Is it possible to insert into a table based on a select from another table?
> 
> The docs for SELECT INTO and like seem to imply you can only create a table
> based on a select, not append to an existing table.

Sure, do INSERT INTO ... SELECT.  

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610) 853-3000 +  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Select into

От:
Jean-Michel Chabanne <jeanmichel.chabanne@free.fr>
Дата:
Christopher Kings-Lynne wrote:

> Hi All,
> 
> Is it possible to insert into a table based on a select from another
> table?
> 
> The docs for SELECT INTO and like seem to imply you can only create a
> table based on a select, not append to an existing table.
> 
> How do you do this?
> 
> Chris
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 

You have to use another syntaxe form :

INSERT INTO target_table (COLx,COLy....) select COLa,COLB... from 
source-table [where ...]

-- 
Jean-Michel Chabanne
77450 MONTRY (FRANCE)
48" 54' N - 2" 49' E
Powered by Linux

FAQ