Jest to schemat mojego stołu web_book:postgreSQL: jak duplikat wiersz
Column | Type | Modifiers
----------------+------------------------+-------------------------------------------------------
id | integer | not null default nextval('web_book_id_seq'::regclass)
page_count | integer | not null
year_published | integer | not null
file | character varying(100) | not null
image | character varying(100) | not null
display_on_hp | boolean | not null
name | character varying(128) | not null
description | text | not null
name_cs | character varying(128) |
name_en | character varying(128) |
description_cs | text |
description_en | text |
Tabela zawiera jeden wiersz z id=3
. Chcę duplikat wiersz ale gdy próbuję to:
INSERT INTO web_book SELECT * FROM web_book WHERE id=3;
uzyskać to:
ERROR: duplicate key value violates unique constraint "web_book_pkey"
DETAIL: Key (id)=(3) already exists
@clime Od 'nextval' jest domyślną dla' id' kolumnie nie jest konieczne, aby go zgłosić. 'INSERT INTO web_book ( page_count, ...) SELECT page_count, ...' –
@ ClodoaldoNeto: dzięki, dobry punkt. Dodałem to. –
Rozumiem. Dziękuję Ci! – clime