X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E69C2D1B179 for ; Fri, 2 Jul 2004 17:31:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55404-10 for ; Fri, 2 Jul 2004 20:31:32 +0000 (GMT) Received: from lerami.lerctr.org (lerami.lerctr.org [192.147.25.11]) by svr1.postgresql.org (Postfix) with ESMTP id 35AD9D1B537 for ; Fri, 2 Jul 2004 17:31:28 -0300 (ADT) Received: from lerlaptop.lerctr.org ([192.147.25.14] helo=lerlaptop) by lerami.lerctr.org with asmtp (Exim 4.34) id 1BgUgz-0004RH-7J; Fri, 02 Jul 2004 15:31:30 -0500 From: "Larry Rosenman" To: , Subject: Re: SERIAL type not autoincremented Date: Fri, 2 Jul 2004 15:30:54 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: <20040702194010Z137290-15166+26852@kps2.test.onet.pl> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Thread-Index: AcRgbrMPXruhoKkNQKydbG2EWgZVAAABJjIg Message-ID: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/52 X-Sequence-Number: 14120 teknet@poczta.onet.pl wrote: > i found the problem: > > > > sys=> create table test2( > sys(> id serial, > sys(> name varchar(10), > sys(> primary key(id) > sys(> ); > NOTICE: CREATE TABLE will create implicit sequence "test2_id_seq" > for "serial" column "test2.id" > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index > "test2_pkey" for table "test2" > CREATE TABLE > sys=> insert into test2 values(1,'myname'); INSERT 18765 1 sys=> > insert into test2 (name) values('myname2'); ERROR: duplicate key > violates unique constraint "test2_pkey" > sys=> > > > Why is it so ? > > > > Thanx > > Michal Because you didn't let the serial column do it's magic. Try: Insert into test2(name) values('myname'); Insert into test2(name) values('myname2'); That should work. Always let a serial column pick the number. LER -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749