Received: from candle.pha.pa.us (maillist@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.8.8/8.7.5) with ESMTP id OAA14278 for ; Tue, 19 May 1998 14:41:28 -0400 (EDT) Received: (from maillist@localhost) by candle.pha.pa.us (8.8.5/8.8.5) id OAA21176; Tue, 19 May 1998 14:38:32 -0400 (EDT) From: Bruce Momjian Message-Id: <199805191838.OAA21176@candle.pha.pa.us> Subject: Re: [SQL] How to handle a requirement for nextval To: herouth@oumail.openu.ac.il (Herouth Maoz) Date: Tue, 19 May 1998 14:38:32 -0400 (EDT) Cc: wwwadmin@wizard.ca, pgsql-sql@postgreSQL.org In-Reply-To: from "Herouth Maoz" at May 19, 98 10:27:50 am X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Update FAQ. See web site for new heading. > > At 23:33 +0300 on 18/5/98, The Web Administrator wrote: > > > > What I want is that the Primary Key (Only Key) be type_id, and int, and > > the first item that I insert should have type_id as '1', next will be > > '2' etc.. > > I could have every insert into this table include a type_id, but that > > seems unessary. > > Can I have something like default='nextval' ? > > This is so much a faq, that I went to look at the FAQ. In fact, there is a > question there which is similar to this one, but I think its phrasing > defeats newbies rather than helps them. I for one have never encountered > fields of type SERIAL, and people might not think it's the same sort of > question. The answer is even more of a problem, because the most commonly > used method of doing this is summarised in "look at the create_sequence > manual", whereas the two less recommended methods (using OIDs and using an > auto-incrementing function) are discussed in detail. > > Bruce, don't you agree? Perhaps change the phrasing of the question to "How > do I create an auto-incrementing field?" -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)