pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Insert values from one existing table into a new table.
4+ messages / 3 participants
[nested] [flat]

* Insert values from one existing table into a new table.
@ 2001-11-13 16:43 Jason <jzhu@dental.temple.edu>
  2001-11-13 21:33 ` Re: Insert values from one existing table into a new table. Wilco Boschman <w.boschman@xs4all.nl>
  2001-11-15 15:48 ` Re: Insert values from one existing table into a new table. Jeff Eckermann <jeff_eckermann@yahoo.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Jason @ 2001-11-13 16:43 UTC (permalink / raw)
  To: pgsql-sql

I want to insert the existing values of one table into a new table.  It
needs the combination of  these to sql commands:

"  insert into new_table values ( values_of_AtrributeA,
values_of_AttributesB) "
" select AttributeA, AttributeB from some_table "

Thanks for your suggestions!  -- Jason






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Insert values from one existing table into a new table.
  2001-11-13 16:43 Insert values from one existing table into a new table. Jason <jzhu@dental.temple.edu>
@ 2001-11-13 21:33 ` Wilco Boschman <w.boschman@xs4all.nl>
  1 sibling, 0 replies; 4+ messages in thread

From: Wilco Boschman @ 2001-11-13 21:33 UTC (permalink / raw)
  To: pgsql-sql

Assuming that the structure of the tables are identical, you could do a:

insert into new_table
  select * from some_table;

If they are not the same you could do a:

insert into new_table (column1, column2)
  select column1, column2 from some_table;

Cheers,

Wilco Boschman


"Jason" <jzhu@dental.temple.edu> schreef in bericht
news:9srij6$gre$1@cronkite.temple.edu...
| I want to insert the existing values of one table into a new table.  It
| needs the combination of  these to sql commands:
|
| "  insert into new_table values ( values_of_AtrributeA,
| values_of_AttributesB) "
| " select AttributeA, AttributeB from some_table "
|
| Thanks for your suggestions!  -- Jason
|
|
|





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Insert values from one existing table into a new table.
  2001-11-13 16:43 Insert values from one existing table into a new table. Jason <jzhu@dental.temple.edu>
@ 2001-11-15 15:48 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
  2001-11-16 16:19   ` Re: Insert values from one existing table into a new table. Jeff Eckermann <jeff_eckermann@yahoo.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Jeff Eckermann @ 2001-11-15 15:48 UTC (permalink / raw)
  To: Jason <jzhu@dental.temple.edu>; pgsql-sql

Lose the quotes, add a semicolon, and you already have
the correct syntax :-)
--- Jason <jzhu@dental.temple.edu> wrote:
> I want to insert the existing values of one table
> into a new table.  It
> needs the combination of  these to sql commands:
> 
> "  insert into new_table values (
> values_of_AtrributeA,
> values_of_AttributesB) "
> " select AttributeA, AttributeB from some_table "
> 
> Thanks for your suggestions!  -- Jason
> 
> 
> 
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster


__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Insert values from one existing table into a new table.
  2001-11-13 16:43 Insert values from one existing table into a new table. Jason <jzhu@dental.temple.edu>
  2001-11-15 15:48 ` Re: Insert values from one existing table into a new table. Jeff Eckermann <jeff_eckermann@yahoo.com>
@ 2001-11-16 16:19   ` Jeff Eckermann <jeff_eckermann@yahoo.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Jeff Eckermann @ 2001-11-16 16:19 UTC (permalink / raw)
  To: Jeff Eckermann <jeff_eckermann@yahoo.com>; Jason <jzhu@dental.temple.edu>; pgsql-sql

Whoops: should also lose the "values", i.e.:
INSERT INTO new_table (values_of_AttributeA,
values_of_AttributesB)
SELECT AttibuteA, AttributeB
FROM some_table;

--- Jeff Eckermann <jeff_eckermann@yahoo.com> wrote:
> Lose the quotes, add a semicolon, and you already
> have
> the correct syntax :-)
> --- Jason <jzhu@dental.temple.edu> wrote:
> > I want to insert the existing values of one table
> > into a new table.  It
> > needs the combination of  these to sql commands:
> > 
> > "  insert into new_table values (
> > values_of_AtrributeA,
> > values_of_AttributesB) "
> > " select AttributeA, AttributeB from some_table "
> > 
> > Thanks for your suggestions!  -- Jason
> > 
> > 
> > 
> > 
> > ---------------------------(end of
> > broadcast)---------------------------
> > TIP 4: Don't 'kill -9' the postmaster
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Find the one for you at Yahoo! Personals
> http://personals.yahoo.com
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please
> send an appropriate
> subscribe-nomail command to majordomo@postgresql.org
> so that your
> message can get through to the mailing list cleanly


__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2001-11-16 16:19 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-11-13 16:43 Insert values from one existing table into a new table. Jason <jzhu@dental.temple.edu>
2001-11-13 21:33 ` Wilco Boschman <w.boschman@xs4all.nl>
2001-11-15 15:48 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
2001-11-16 16:19   ` Jeff Eckermann <jeff_eckermann@yahoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox