Re: reordering sequences

From: "Gregory Wood" <gregw(at)com-stock(dot)com>
To: "mike" <matrix(at)quadrent(dot)net>
Cc: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: reordering sequences
Date: 2001-07-11 16:21:49
Message-ID: 018d01c10a25$99c7cb40$7889ffcc@comstock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> is it at all possiable to reorder a squence? I'm finding that our
sequences get some what out step and messed and would like to ocassionaly
reorder them, though I'm unable to find anything that might be able to do
this.

BEGIN;
SELECT setval('MyTable_MySeq_SEQ',1);
UPDATE MyTable SET MySeq=nextval('MyTable_MySeq_SEQ');
COMMIT;

Of course this will screw up any foreign keys that you have that don't have
an ON UPDATE CASCADE set on them. Also, this is not guaranteed to preserve
the current sequence order, if that's important to you.

Greg

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2001-07-11 16:37:07 Re: Toast question
Previous Message Dave Cramer 2001-07-11 16:14:58 RE: JDBC and stored procedures