Re: change existing table definition

From: "Lee Wu" <Lwu(at)mxlogic(dot)com>
To: <chen(at)musc(dot)edu>, "Peter Eisentraut" <peter_e(at)gmx(dot)net>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: change existing table definition
Date: 2005-06-28 15:34:44
Message-ID: E1F0E4D89D8FA44789DFC065C8E755281A364B@mxlhq-exch01.corp.mxlogic.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

In PG 7, you can add column like:
create table test (c1 varchar(30));
alter table test add column c2 int;
select version();
version
-------------------------------------------------------------
PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.96
(1 row)

I do not know you can alter field/column length in PG 8 and it can be
done in PG 8:
select version();
version
------------------------------------------------------------------------
----------------------------------
PostgreSQL 8.0.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
20030502 (Red Hat Linux 3.2.3-49)
(1 row)
alter table test alter c1 type varchar(50);

I think in PG, you can:
1. add a new right length column like shown
2. update test set new_column=old_column;
3. alter table drop old_column

-----Original Message-----
From: pgsql-admin-owner(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Chuming Chen
Sent: Tuesday, June 28, 2005 8:40 AM
To: Peter Eisentraut
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] change existing table definition

Peter Eisentraut wrote:

>Chuming Chen wrote:
>
>
>>How can I change the column definition of an existing table, ie. from
>>varchar(30) to varchar(50)? Is there any way to add a new column to
>>an existing table?
>>
>>
>
>The ALTER TABLE command can do all that. You need version 8.0 or later

>for some functionality though.
>
>
>
Is there another way to do it in 7.* ?

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Marlowe 2005-06-28 15:41:33 Re: How to compare the schemas ?
Previous Message Martin Fandel 2005-06-28 15:29:11 Re: change existing table definition