Re: Renaming a sequence?

From: "Andy Shellam" <andy(dot)shellam(at)mailnetwork(dot)co(dot)uk>
To: <ogjunk-pgjedan(at)yahoo(dot)com>, <pgsql-admin(at)postgresql(dot)org>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Renaming a sequence?
Date: 2006-03-25 17:49:45
Message-ID: 20060325174957.ADB2E9DC98B@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

You also need to alter your column's default value to point to your new
sequence (nextval('public.watchlist_id_seq'::text)).

I'm not certain of the SQL to do this but must be along the order of "ALTER
COLUMN <tablename>.<column name> DEFAULT
nextval('public.watchlist_id_seq'::text)" or something similar.

Andy

-----Original Message-----
From: pgsql-admin-owner(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of
ogjunk-pgjedan(at)yahoo(dot)com
Sent: Saturday, 25 March, 2006 3:23 am
To: pgsql-admin(at)postgresql(dot)org
Subject: [ADMIN] Renaming a sequence?

Hi,

I just renamed some of my tables, but I now have sequences with older names.

I followed info from
http://www.postgresql.org/docs/current/static/sql-altersequence.html :

"Some variants of ALTER TABLE can be used with sequences as well; for
example, to rename a sequence use ALTER TABLE RENAME"

So this is what I did:

ALTER TABLE topic_id_seq RENAME TO watchlist_id_seq;

That *appeared* to work, but I still see the old sequence name:

mydb => \d watchlist
Table "public.watchlist"
Column | Type | Modifiers
--------------+-------------------------------+-----------------------------
--------------------------
id | integer | not null default
nextval('public.topic_id_seq'::text)
...
Indexes:
"pk_topic_id" PRIMARY KEY, btree (id)

It looks like my sequence WAS renamed, but my table's PK points to the old
sequence name, which is not supposed to exist any more. Is there any way to
change this without killing the sequence?

Thanks,
Otis

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

!DSPAM:14,4424b7b935047329715045!

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Andy Shellam 2006-03-25 17:51:13 Re: WAL file naming convention
Previous Message Jerry Sievers 2006-03-25 16:08:03 pg_stat_activity showing non-existent processes