Received: from danbo.digsys.bg (root@danbo.digsys.bg [192.92.129.10]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA70330 for ; Fri, 7 Jan 2000 10:56:55 -0500 (EST) (envelope-from vlady@school.digsys.bg) Received: from school.digsys.bg (vlady@school.digsys.bg [193.68.6.1]) by danbo.digsys.bg (8.9.0/8.9.0) with ESMTP id RAA00148; Fri, 7 Jan 2000 17:56:45 +0200 (EET) Received: from localhost (vlady@localhost) by school.digsys.bg (8.8.5/8.8.5) with ESMTP id RAA06354; Fri, 7 Jan 2000 17:56:45 +0200 (EET) Date: Fri, 7 Jan 2000 17:56:45 +0200 (EET) From: Vladimir Terziev To: Richard Walker cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Serial field starting at 100 ? In-Reply-To: <20000107023509.41287.qmail@hotmail.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi Richard, You can do the next: create sequence fish_seq start 100; create table fish( fishID int default nextval('fDish_seq') not null, fishName varchar(32) not null ); The action of the above is what you want! Vladimir On Fri, 7 Jan 2000, Richard Walker wrote: > Hello, > > In SQLServer, you can do this: > > CREATE TABLE fish ( > fishID INTEGER IDENTITY (100, 1) NOT NULL, > fishName VARCHAR(32) NOT NULL > ); > > When inserting into that table, you don't mention the first field > and it will automatically use add 1 to the last value in that field, > starting with 100 for the first record. > If you wanted it to start at 25 and increment by 5, you'd put > fishID INTEGER IDENTITY (25, 5) NOT NULL. > > I'd like to do something similar to this in PostgreSQL, but the > closest I can get requires that I mention the implicit sequence which > seems unneccessary hassle: > > CREATE TABLE fish ( > fishID INT4 SERIAL > fishName VARCHAR(32) NOT NULL > ); > > SELECT setval('fish_fishID_seq',99); > > (Incrementing by 1 is fine by me). > Is there any way I can do something like: > fishID INT4 SERIAL (100, 1) > or > fishID INT4 SERIAL (START 100) ? > > - Rick > > > ______________________________________________________ > Get Your Private, Free Email at http://www.hotmail.com > > > ************ > >