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 07:06:12 |
Message-ID: | T5ce28a8478ac1785c31d7@pcow058m.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
Like I said I make a lot of typo's
What I meant to write was:
begin;
ALTER table table0 RENAME TO table1;
DROP INDEX table0_pkey;
CREATE TEMPORARY table table1temp() INHERITS (table1);
INSERT INTO table1temp SELECT * FROM table1;
CREATE table table0(
field varchar(50) PRIMARY KEY);
INSERT INTO table0 SELECT * FROM table1temp;
DROP table table1temp;
DROP table table1;
end;
Though looking at it again I'm not sure why I used the temporary
table, this seems to work as well:
begin;
ALTER table table0 RENAME TO table1;
DROP INDEX table0_pkey;
CREATE table table0(
field varchar(50) PRIMARY KEY);
INSERT INTO table0 SELECT * FROM table1;
DROP table table1;
end;
Watch out for the data in the old column(100) being too big for the
new one (50),
Hope this actually 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)
From | Date | Subject | |
---|---|---|---|
Next Message | Aarni Ruuhimäki / Megative Tmi / KYMI.com | 2002-08-23 07:52:01 | Re: changing the size of a column without losing data |
Previous Message | paul butler | 2002-08-23 06:21:01 | Re: changing the size of a column without losing data |