pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-general@postgresql.org
Subject: Re: copy record?
Date: 27 May 2011 04:45:47 GMT
Message-ID: <irna9r$dso$3@reversiblemaps.ath.cx> (raw)
References: <482E80323A35A54498B8B70FF2B87980049413B5EB@azsmsx504.amr.corp.intel.com>
	<482E80323A35A54498B8B70FF2B87980049413B673@azsmsx504.amr.corp.intel.com>
	<4DDEC3B1.2050008@boscorama.com>

On 2011-05-26, Bosco Rama <postgres@boscorama.com> wrote:

>   select * into temp table foo from maintable where primcol=123;
>   update foo set primcol = 456;
>   insert into maintable select * from foo;
>
> You also may need this is if you intend to use the same sequence of
> calls on within the same session:
>
>   drop table foo;

Yet another way to do the same thing:

begin;

create temportary table foo on commit drop as
 select * from maintable where primcol=123;
update foo, set primcol=456;
insert into maintable select * from foo;

commit;

-- 
⚂⚃ 100% natural




view thread (5+ messages)  latest in thread

Message-ID: <irna9r$dso$3@reversiblemaps.ath.cx>
Permalink:  ../irna9r$dso$3@reversiblemaps.ath.cx/
Also on:    postgresql.org/message-id/irna9r$dso$3@reversiblemaps.ath.cx

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasen@xnet.co.nz, pgsql-general@postgresql.org
  Subject: Re: copy record?
  In-Reply-To: <irna9r$dso$3@reversiblemaps.ath.cx>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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