Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id AA77E9FA2C2 for ; Tue, 17 Jul 2007 10:34:46 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 89296-05 for ; Tue, 17 Jul 2007 10:34:37 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 15FB39FB5ED for ; Tue, 17 Jul 2007 10:34:43 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IAnCD-0004vj-Tv for pgsql-sql@postgresql.org; Tue, 17 Jul 2007 15:34:33 +0200 Received: from smcgraw.ppp.frii.com ([216.17.133.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Jul 2007 15:34:33 +0200 Received: from smcg2297 by smcgraw.ppp.frii.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Jul 2007 15:34:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: "Stuart" Subject: Re: data dependent sequences? Date: Tue, 17 Jul 2007 07:34:26 -0600 Lines: 31 Message-ID: References: <1184515497.5778.141.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: smcgraw.ppp.frii.com X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.134 tagged_above=0 required=5 tests=AWL=0.133, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200707/98 X-Sequence-Number: 28833 "Ragnar" wrote in message news:1184515497.5778.141.camel@localhost.localdomain... > On sun, 2007-07-15 at 09:28 -0600, Stuart McGraw wrote: > > Advice requested :-) I have a table like: > > > > CREATE TABLE items ( > > id INT, > > typ INT ... > > PRIMAY KEY (seq,typ)); > > > > I would like 'id' to be like a SERIAL except that I > > want independent sequences for each value of 'typ'. > > what possible advantage could there be to that? > > if you need gapless series, then sequences (and serial) > are not adequate anyways. > > just use one sequence. I am not looking for gapless sequences. The reason I want to do this is the "typ" column is actually an indicator of the source of the rest of the infomation in the row. The "rules" for assigning the id number vary depending on the source -- in some cases they start at 1 and increment by one, in other cases they start at, say, 1000000 and increment by 10. There are a lot existing data using these rules and I cannot change that. I can of course have the application do the assignments, but in general eould prefer to push this down into the database if posible.