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 7206BD1B392 for ; Fri, 2 Jul 2004 15:32:03 -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 00959-06 for ; Fri, 2 Jul 2004 18:32:01 +0000 (GMT) Received: from lithium.sunwave.net (lithium.sunwave.net [64.141.16.21]) by svr1.postgresql.org (Postfix) with ESMTP id 9502BD1B384 for ; Fri, 2 Jul 2004 15:31:58 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lithium.sunwave.net (Postfix) with ESMTP id 57B1D44126; Fri, 2 Jul 2004 11:31:58 -0700 (PDT) Received: from lithium.sunwave.net ([127.0.0.1]) by localhost (lithium.sunwave.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 08261-01-61; Fri, 2 Jul 2004 11:31:58 -0700 (PDT) Received: from starbucks.in.sunwave.net (fw1-et-1.sunwave.net [64.141.16.15]) by lithium.sunwave.net (Postfix) with ESMTP id 21D8C43EB1; Fri, 2 Jul 2004 11:31:58 -0700 (PDT) From: Michael A Nachbaur To: teknet@poczta.onet.pl Subject: Re: SERIAL type not autoincremented Date: Fri, 2 Jul 2004 11:31:57 -0700 User-Agent: KMail/1.6.1 Cc: pgsql-admin@postgresql.org References: <20040702172227Z4873738-14310+28550@kps5.test.onet.pl> In-Reply-To: <20040702172227Z4873738-14310+28550@kps5.test.onet.pl> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200407021131.57987.mike@nachbaur.com> 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/46 X-Sequence-Number: 14114 The serial datatype creates a sequence in the background. So, in your example, you'll have a sequence called "student_id_seq". Your sequence was probably reset, dropped/created, or whatever, to cause it to feed IDs back that already exist in your table. On July 2, 2004 10:22 am, teknet@poczta.onet.pl wrote: > Hello > i have: > create table student( > id SERIAL NOT NULL, > name VARCHAR(35) NOT NULL, > primary key (id) > ); > > and when i try to insert like this: > insert into student (name) values('me'); > i receive error: > ERROR: duplicate key violates unique constraint "student_pkey" > > Why ? Do i understeand correctly that SERIAL == AUTO_INCREMENT ? > As far as i remember i used such type in the past and had no problem. > What do i miss ? > > Thanx > Michal > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend -- Michael A. Nachbaur http://nachbaur.com/pgpkey.asc