Re: ALTER TABLE RENAME column

From: "Mario Weilguni" <mario(dot)weilguni(at)icomedias(dot)com>
To: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Jim Nasby" <decibel(at)decibel(dot)org>, "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER TABLE RENAME column
Date: 2006-11-17 15:30:46
Message-ID: FA095C015271B64E99B197937712FD020E4B0EE7@freedom.grz.icomedias.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Right, but I think jim means automatical renames of sequences, and especially something like this:
db=# CREATE TABLE foo (bar serial);
NOTICE: CREATE TABLE will create implicit sequence "foo_bar_seq" for serial column "foo.bar"
CREATE TABLE
db=# ALTER TABLE foo rename bar to baf;
ALTER TABLE
db=# \d foo
Table "public.foo"
Column | Type | Modifiers
--------+---------+---------------------------------------------------
baf | integer | not null default nextval('foo_bar_seq'::regclass)

The sequence still is named "foo_bar_seq".

IMO this should do:
Alter sequence foo_bar_seq rename to foo_baf_seq;
Alter table foo alter baf set default nextval('foo_baf_seq')

-----Ursprüngliche Nachricht-----
Von: Jonah H. Harris [mailto:jonah(dot)harris(at)gmail(dot)com]
Gesendet: Freitag, 17. November 2006 16:27
An: Mario Weilguni
Cc: Tom Lane; Jim Nasby; PostgreSQL Hackers
Betreff: Re: [HACKERS] ALTER TABLE RENAME column

On 11/17/06, Mario Weilguni <mario(dot)weilguni(at)icomedias(dot)com> wrote:
> Sounds like this is not done, at least not renaming sequencens and constraints, or am I wrong here?

To rename a sequence or a table:

ALTER TABLE yo_table RENAME TO yo_new_table; ALTER TABLE yo_sequence RENAME TO yo_new_sequence;

Or am I mistaken?

--
Jonah H. Harris, Software Architect | phone: 732.331.1300
EnterpriseDB Corporation | fax: 732.331.1301
33 Wood Ave S, 2nd Floor | jharris(at)enterprisedb(dot)com
Iselin, New Jersey 08830 | http://www.enterprisedb.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-11-17 15:37:35 Re: ALTER TABLE RENAME column
Previous Message Jonah H. Harris 2006-11-17 15:27:39 Re: ALTER TABLE RENAME column