Re: rename a table

From: "Thalis A(dot) Kalfigopoulos" <thalis(at)cs(dot)pitt(dot)edu>
To: Kostis Mentzelos <mentzelos(at)ematic(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: rename a table
Date: 2001-06-22 20:26:22
Message-ID: Pine.LNX.4.21.0106221624320.27771-100000@aluminum.cs.pitt.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Only declare the attribute 'b' as serial the first time. From then on, whenever you recreate table DATA just declare: b int default nextval('data_b_seq'::text)

cheers,
thalis

On Thu, 21 Jun 2001, Kostis Mentzelos wrote:

> Hi all,
>
> I want to rename a table from DATA to 'unique' every month
> and then recreate table DATA. (a number of applications works
> with table DATA)
>
> DATA contains among the others a SERIAL field.
>
> create table DATA (a int, b serial,...);
>
> I tried ALTER TABLE DATA RENAME TO XXXX but
> when I recreate table DATA I get this error:
> relation 'data_b_seq' already exists.
>
> Is there any way to rename sequences?
> Is it better to create the new table, copy 1.000.000 to the new
> table and then delete them from DATA and then VACCUM the
> database?
>
> kostis.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Yasuo Ohgaki 2001-06-22 21:50:06 Re: List of DDL commands?
Previous Message Dave Cramer 2001-06-22 19:09:40 RE: Re: [ADMIN] High memory usage [PATCH]