Re: changing the size of a column without losing data

From: "paul butler" <paul(at)entropia(dot)co(dot)uk>
To: "Mark Seftel" <mark(at)trustemail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: changing the size of a column without losing data
Date: 2002-08-23 06:21:01
Message-ID: T5ce2612611ac1785c21bc@pcow053o.blueyonder.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

From: "Mark Seftel" <mark(at)trustemail(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: [NOVICE] changing the size of a column without losing data
Date sent: Thu, 22 Aug 2002 19:43:57 +0200

Mark

Alter colummn isn't implemented beyond renaming as far as I know,

I do it by brute force, eg:

Begin;
ALTER TABLE table RENAME TO table2;

DROP INDEX table_pkey;

CREATE TEMPORARY TABLE tabletemp() INHERITS (table2);

INSERT INTO tabletemp SELECT * FROM table2;

CREATE TABLE table(
field varchar(150) PRIMARY KEY);

INSERT INTO table SELECT * FROM tabletemp;

DROP table2;

DROP tabletemp;

End;

I always do these things in a transaction (wonderful things) as I
often make typo's

Hope this helps

Paul Butler

> hi,
>
> How would i change a field which is currently char100 to char50?
>
> have tried:
> ALTER TABLE outlets MODIFY description varchar(50);
>
> but get error:
> parser: parse error at or near "modify"
>
> what is the correct command.
>
> Thx
>
> Mark
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message paul butler 2002-08-23 07:06:12 Re: changing the size of a column without losing data
Previous Message Larry Rosenman 2002-08-22 18:16:24 Re: Enforcing Case