Re: change existing table definition - Mailing list pgsql-admin

From Lee Wu
Subject Re: change existing table definition
Date
Msg-id E1F0E4D89D8FA44789DFC065C8E755281A364B@mxlhq-exch01.corp.mxlogic.com
Whole thread Raw
In response to change existing table definition  (Chuming Chen <chen@musc.edu>)
List 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@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Chuming Chen
Sent: Tuesday, June 28, 2005 8:40 AM
To: Peter Eisentraut
Cc: pgsql-admin@postgresql.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@postgresql.org

pgsql-admin by date:

Previous
From: Johannes Lochmann
Date:
Subject: Re: change existing table definition
Next
From: Scott Marlowe
Date:
Subject: Re: How to compare the schemas ?