pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedNeed to change the size of a field
4+ messages / 4 participants
[nested] [flat]
* Need to change the size of a field
@ 2002-02-18 13:30 suresh@mithi.com
2002-02-18 13:56 ` Re: Need to change the size of a field Nick Fankhauser <nickf@ontko.com>
2002-02-18 14:23 ` Re: Need to change the size of a field postgresql <pgsql@symcom.com>
2002-02-18 18:24 ` Re: Need to change the size of a field Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 3 replies; 4+ messages in thread
From: suresh@mithi.com @ 2002-02-18 13:30 UTC (permalink / raw)
To: pgsql-sql
Hi
I have a table with one of the fields as a varchar(32) field. This table has
about 100,000 records.
I want to increase the size of the varchar field to 64. How can this be done
without affecting the data already present ?
Thanx in advance.
regards
suresh
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Need to change the size of a field
2002-02-18 13:30 Need to change the size of a field suresh@mithi.com
@ 2002-02-18 13:56 ` Nick Fankhauser <nickf@ontko.com>
2 siblings, 0 replies; 4+ messages in thread
From: Nick Fankhauser @ 2002-02-18 13:56 UTC (permalink / raw)
To: suresh@mithi.com; pgsql-sql
I don't think you can alter a column in the current version, but here's an
example of a workaround that should do the job:
create table change_me (id int, text varchar(20));
[Then I add some data & decide I need to widen the text field without losing
the data.]
create table temp_change_me as select * from change_me;
drop table change_me;
create table change_me (id int, text varchar(50));
insert into change_me (id, text) (select id, text from temp_change_me);
drop table temp_change_me;
hth, Nick
> -----Original Message-----
> From: pgsql-sql-owner@postgresql.org
> [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of suresh@mithi.com
> Sent: Monday, February 18, 2002 8:31 AM
> To: pgsql-sql@postgresql.org
> Subject: [SQL] Need to change the size of a field
>
>
> Hi
>
> I have a table with one of the fields as a varchar(32) field.
> This table has
> about 100,000 records.
> I want to increase the size of the varchar field to 64. How can
> this be done
> without affecting the data already present ?
> Thanx in advance.
> regards
> suresh
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Need to change the size of a field
2002-02-18 13:30 Need to change the size of a field suresh@mithi.com
@ 2002-02-18 14:23 ` postgresql <pgsql@symcom.com>
2 siblings, 0 replies; 4+ messages in thread
From: postgresql @ 2002-02-18 14:23 UTC (permalink / raw)
To: suresh@mithi.com; pgsql-sql
suresh
This is pretty simple.... Just do a pg_dump of the of the database,
edit the text file, and reimport the new definitions.
something like
dg_dump 'targetdb' > outputfile
This is the same thing you are doing to backup your data. : )
Next open the outputfile in a text editor. Notice that you have all the
create table directives. Edit the value in the definition area and save
the file.
drop the original database. then reimport the dump file (you will first
have to createdb because you dropped it remember).
That's it. Your pg_dump files are your friends.
Ted
-----Original Message-----
From: <suresh@mithi.com>
To: <pgsql-sql@postgresql.org>
Date: Mon, 18 Feb 2002 19:00:49 +0530
Subject: [SQL] Need to change the size of a field
> Hi
>
> I have a table with one of the fields as a varchar(32) field. This
> table has
> about 100,000 records.
> I want to increase the size of the varchar field to 64. How can this
be
> done
> without affecting the data already present ?
> Thanx in advance.
> regards
> suresh
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Need to change the size of a field
2002-02-18 13:30 Need to change the size of a field suresh@mithi.com
@ 2002-02-18 18:24 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2 siblings, 0 replies; 4+ messages in thread
From: Stephan Szabo @ 2002-02-18 18:24 UTC (permalink / raw)
To: suresh@mithi.com; +Cc: pgsql-sql
On Mon, 18 Feb 2002 suresh@mithi.com wrote:
> Hi
>
> I have a table with one of the fields as a varchar(32) field. This table has
> about 100,000 records.
> I want to increase the size of the varchar field to 64. How can this be done
> without affecting the data already present ?
Dump and restore after changing the field length is usually easiest, but
if you don't mind a little hacking in the system tables, check out the
archives and you'll find the particular recipe for doing it.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-02-18 18:24 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-18 13:30 Need to change the size of a field suresh@mithi.com
2002-02-18 13:56 ` Nick Fankhauser <nickf@ontko.com>
2002-02-18 14:23 ` postgresql <pgsql@symcom.com>
2002-02-18 18:24 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox