Copying a row within table

From: Aarni Ruuhimäki <aarni(at)kymi(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Copying a row within table
Date: 2006-03-14 07:19:49
Message-ID: 200603140919.49246.aarni@kymi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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
--------------

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message John Sidney-Woollett 2006-03-14 07:56:31 Re: Update value to "the first character is capital and
Previous Message Eugene E. 2006-03-14 06:10:01 Re: Permission to Select -- I am wrong