From: Uwe C. Schroeder <uwe@oss4u.com>
To: pgsql-admin@postgresql.org
Subject: Sequence update function?
Date: Mon, 11 Jun 2007 18:25:56 -0700
Message-ID: <200706111825.56480.uwe@oss4u.com> (raw)
Hi,
just thought I ask before I start doing it myself: Has anyone ever written a
stored procedure (or any other means) of syncing the sequence to the max #
key in the corresponding tables?
I'm running a simple script to update table contents between dev and
production system, however the script is flawed in the way that it copied the
primary key along (it's a simple pg_dump|pg-restore shellscript). It works
fine because all rows that are already there just fail for PK violation.
In the end I'm ending up with sequences out of sync. So i though a simple
little helper that loops over the sequences (information schema), grabs the
according table, does a max(key) on the table and sets the sequence to that
will do nicely.
Anyone written something like that?
Thanks
UC
--
Open Source Solutions 4U, LLC 1618 Kelly St
Phone: +1 707 568 3056 Santa Rosa, CA 95401
Cell: +1 650 302 2405 United States
Fax: +1 707 568 6416
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: uwe@oss4u.com
Subject: Re: Sequence update function?
In-Reply-To: <200706111825.56480.uwe@oss4u.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox