Re: Change size of varchar(20) field

From: Frank Bax <fbax(at)sympatico(dot)ca>
To: Elaine Lindelef <eel(at)cognitivity(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Change size of varchar(20) field
Date: 2002-02-04 20:12:03
Message-ID: 3.0.6.32.20020204151203.028645d0@pop6.sympatico.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You could add "-o" option to pg_dump in option (b) to preserve oid's.

At 11:08 AM 2/4/02 -0800, Elaine Lindelef wrote:
>>You can either:
>>
>>a) create table unittemp as select field1, field2, cast(room as
>>varchar(20)), ..., fieldn from unit;
>> drop table unit;
>> alter table unittemp rename to unit;
>>
>>b) pg_dump -t unit [dbname] > unit.pgsql
>> edit unit.pgsql and change varchar(20) to varchar(40) and add a line to
>>beginning of file "drop table unit"
>> pgsql [dbname] < unit.pgsql
>>
>>Frank
>>
>>At 12:03 PM 2/4/02 -0500, David A Dickson wrote:
>> >I have a tabl called 'unit' with a field 'room' of type character
>> >varying(20). I want to change the type to character varying(40).
>> >How do I do this without affecting any data in the table.
>
>Has anyone discovered any workaround to the lack of a full ALTER
>TABLE that preserves the OID for each row? I am finding that for
>insurance I have to assign each table an SERIAL of my own to create
>an autoincremented ID that I can control - because using OID as a key
>requires me to update the key throughout the database if I have to
>drop the table.
>
>Elaine Lindelef

In response to

Browse pgsql-general by date

  From Date Subject
Next Message david blood 2002-02-04 20:17:27 Long column names and table names
Previous Message Tom Lane 2002-02-04 20:04:16 Re: Surprise AT TIME ZONE behaviour (buglet?)?