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 E7651D1B499 for ; Fri, 2 Jul 2004 18:07:36 -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 71555-10 for ; Fri, 2 Jul 2004 21:07:36 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 64B01D1B44D for ; Fri, 2 Jul 2004 18:07:33 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i62L7XZ5042114 for ; Fri, 2 Jul 2004 21:07:33 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i62KoS4U038985 for pgsql-admin@postgresql.org; Fri, 2 Jul 2004 20:50:28 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.admin Subject: Re: SERIAL type not autoincremented Date: Fri, 02 Jul 2004 16:19:01 -0400 Organization: cbbrowne Computing Inc Lines: 58 Message-ID: References: <20040702172227Z4873738-14310+28550@kps5.test.onet.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:XRYwTETORU7YZgtzd6RQTg9eo7Q= To: pgsql-admin@postgresql.org 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/56 X-Sequence-Number: 14124 Martha Stewart called it a Good Thing when 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 ? cbbrowne@wolfe:~$ psql osdb Welcome to psql 7.4.3, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit /* cbbrowne@[local]/wolfe osdb=*/ create table student( /*osdb(#*/id SERIAL NOT NULL, /*osdb(#*/name VARCHAR(35) NOT NULL, /*osdb(#*/primary key (id) /*osdb(#*/); NOTICE: CREATE TABLE will create implicit sequence "student_id_seq" for "serial" column "student.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "student_pkey" for table "student" CREATE TABLE /* cbbrowne@[local]/wolfe osdb=*/ insert into student (name) values('me'); INSERT 19423269 1 /* cbbrowne@[local]/wolfe osdb=*/ \q It sounds as though there's something more going on that you haven't told us about. What data was already in that table? If there wasn't anything already there, there could hardly be a duplicate. -- let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];; http://www3.sympatico.ca/cbbrowne/lsf.html Academics denigrating "Popularizers" "During the rise of the merchant class, the landed aristocracy understood the value of creating food, but didn't appreciate that food isn't valuable unless it reaches hungry mouths. New ideas aren't valuable unless they reach hungry minds. " -- Mark Miller