X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C3CAF475458 for ; Tue, 18 Feb 2003 08:29:33 -0500 (EST) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id 18E8D474E53 for ; Tue, 18 Feb 2003 08:29:33 -0500 (EST) Received: (qmail 11396 invoked by uid 500); 18 Feb 2003 13:43:11 -0000 Date: Tue, 18 Feb 2003 07:43:11 -0600 From: Bruno Wolff III To: Raymond Pau Cc: pgsql-sql@postgresql.org Subject: Re: How to make sequence skip existing key in table? Message-ID: <20030218134311.GB11307@wolff.to> Mail-Followup-To: Raymond Pau , pgsql-sql@postgresql.org References: <3E51F36A.75F42D3@rodos.fzk.de> <20030218100134.91784.qmail@web14204.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030218100134.91784.qmail@web14204.mail.yahoo.com> User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/398 X-Sequence-Number: 11796 On Tue, Feb 18, 2003 at 02:01:34 -0800, Raymond Pau wrote: > Hi List, Please don't start new threads by replying to other messages on the list. This screws up threading of messages, which is useful for following specific discussions. > I am using sequence to generate to a list of unique > key id that will be used as the primary key for some > tables. > > My question is when the sequence wraps over to the > minimum value(1), how can I ensure that the next id is > not in the tables? My suggestion is to use the bigserial type. This uses bigint as the underlying type and you are not likely to roll over a 64 bit integer unless you are wasting a lot of serial values for each one you actually use.