Re: sequence rename?

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: ben f <benomatic42(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: sequence rename?
Date: 2004-10-03 15:18:33
Message-ID: 20041003151832.GA4800@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 01, 2004 at 01:17:38PM -0700, ben f wrote:
> So I am renaming a table, and the last stumbling block
> that I've met is the associated sequence. I tried the
> commands suggested @
>
> http://mailman.fastxs.net/pipermail/dbmail-dev/2004-August/004307.html
>
> ie:
>
> CREATE SEQUENCE $newseq
> SELECT setval('$newseq', max($column)) FROM $table
> ALTER TABLE $table ALTER COLUMN $column SET DEFAULT
> nextval('$newseq'::text)
> DROP SEQUENCE $oldseq

How about

ALTER TABLE $oldseq RENAME TO $newseq;

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Y eso te lo doy firmado con mis lágrimas" (Fiebre del Loco)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Mair 2004-10-03 15:29:01 Re: earthdistance results seem to be wrong.
Previous Message David Garamond 2004-10-03 14:58:26 guaranteeing that a sequence never skips