pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aarni Ruuhimäki <aarni@kymi.com>
To: pgsql-sql@postgresql.org
Subject: Copying a row within table
Date: Tue, 14 Mar 2006 09:19:49 +0200
Message-ID: <200603140919.49246.aarni@kymi.com> (raw)

Hi people,

testing=# INSERT INTO foo (SELECT * FROM foo WHERE foo_id = 2);
ERROR:  duplicate key violates unique constraint "foo_pkey"
testing=#

testing=# INSERT INTO foo (foo_1, foo_2, foo_3 ...) (SELECT foo_1, foo_2, 
foo_3 ... FROM message_table WHERE foo_id = 10);
INSERT 717286 1
testing=#

Is there a fast way to copy all but not the PK column to a new row within the 
same table so that the new foo_id gets its value from the sequence ?

TIA and BR,

Aarni

-- 
Aarni Ruuhimäki
--------------
This is a bugfree broadcast to you
from **Kmail**
on **Fedora Core** linux system
--------------



view thread (4+ messages)  latest in thread

Message-ID: <200603140919.49246.aarni@kymi.com>
Permalink:  ../200603140919.49246.aarni@kymi.com/
Also on:    postgresql.org/message-id/200603140919.49246.aarni@kymi.com

 · 

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: aarni@kymi.com
  Subject: Re: Copying a row within table
  In-Reply-To: <200603140919.49246.aarni@kymi.com>

* 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