Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D72B1632790 for ; Fri, 10 Apr 2009 15:20:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 85756-02 for ; Fri, 10 Apr 2009 15:20:19 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f167.google.com (mail-ew0-f167.google.com [209.85.219.167]) by mail.postgresql.org (Postfix) with ESMTP id BCC55632763 for ; Fri, 10 Apr 2009 15:20:21 -0300 (ADT) Received: by ewy11 with SMTP id 11so1753751ewy.19 for ; Fri, 10 Apr 2009 11:20:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=2YiaSbeiysPG/M4Lmx5rPDJU70NrKoClv6uPXYLccCA=; b=N8w+RoiRUJFBTEO0MNY7MHWawSeu3b0ZIUWdYkMraJnwWoEb+J5fP5a/xF0q7b++He QqvQVs6x+riJYdfaXDdF7qyQ/HKys6vU71WxTTnPKa90P5qtdysyhVyhKHFA4OvWvr6t +fdBBTfdAMcAXFQye9SNo0jMDwxHHzDgNqmZI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=AKIRNZ2+orts2oKEFr6k6R+4kHYgxAhs984fDrisblnlua8Lk5tyVh3KCl/XvnKAEN 9Q39A4eSPPRS0veVFd/HnkywwWHVTvAv/L9XLk6dNfAWIPzht1EomZPTM/arcCqHLQDw c30WSRZApq2PYbnwDEBeMvIp4B1VXAF8NBgkc= MIME-Version: 1.0 Received: by 10.210.35.5 with SMTP id i5mr438557ebi.24.1239387620244; Fri, 10 Apr 2009 11:20:20 -0700 (PDT) In-Reply-To: <49DC1034.1060705@frii.com> References: <49DC1034.1060705@frii.com> Date: Fri, 10 Apr 2009 12:20:20 -0600 Message-ID: Subject: Re: changing multiple pk's in one update From: Scott Marlowe To: Stuart McGraw Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL=0.002 X-Spam-Level: X-Archive-Number: 200904/52 X-Sequence-Number: 32398 2009/4/7 Stuart McGraw : > Hello all, > > I have a table with a primary key column > that contains sequential numbers. > > Sometimes I need to shift them all up or down > by a fixed amount. =A0For example, if I have > four rows with primary keys, 2, 3, 4, 5, I > might want to shift them down by 1 by doing: > Generally speaking, when you need to do this more than once or twice in the lifetime of your data, there's something wrong with your data model.