pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedChanging the column length
3+ messages / 3 participants
[nested] [flat]
* Changing the column length
@ 2004-09-01 06:42 Michael Ryan S. Puncia <mpuncia@census.gov.ph>
2004-09-01 08:47 ` Re: Changing the column length gnari <gnari@simnet.is>
2004-09-01 16:32 ` Re: Changing the column length Josh Berkus <josh@agliodbs.com>
0 siblings, 2 replies; 3+ messages in thread
From: Michael Ryan S. Puncia @ 2004-09-01 06:42 UTC (permalink / raw)
To: pgsql-performance
Hi ,
I am sorry that my question is out of line with this
group(performance) but I need
an urgent help :-( .pls .. I need to know how to change the length of the
column.
Thanks and hoping that u will not ignore my question
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Changing the column length
2004-09-01 06:42 Changing the column length Michael Ryan S. Puncia <mpuncia@census.gov.ph>
@ 2004-09-01 08:47 ` gnari <gnari@simnet.is>
1 sibling, 0 replies; 3+ messages in thread
From: gnari @ 2004-09-01 08:47 UTC (permalink / raw)
To: Michael Ryan S. Puncia <mpuncia@census.gov.ph>; pgsql-performance
From: "Michael Ryan S. Puncia" <mpuncia@census.gov.ph>
> I am sorry that my question is out of line with this
> group(performance) but I need
-general might be more appropriate
>
> an urgent help :-( .pls .. I need to know how to change the length of the
> column.
add a new column, use update to copy values from old column,
use alter table to rename columns
gnari
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Changing the column length
2004-09-01 06:42 Changing the column length Michael Ryan S. Puncia <mpuncia@census.gov.ph>
@ 2004-09-01 16:32 ` Josh Berkus <josh@agliodbs.com>
1 sibling, 0 replies; 3+ messages in thread
From: Josh Berkus @ 2004-09-01 16:32 UTC (permalink / raw)
To: Michael Ryan S. Puncia <mpuncia@census.gov.ph>; pgsql-performance
Michael,
> I am sorry that my question is out of line with this
> group(performance) but I need
>
> an urgent help :-( .pls .. I need to know how to change the length of the
> column.
In the future, try to provide more detail on your problem. Fortunately, I
think I know what it is.
PostgreSQL does not support changing the length of VARCHAR columns in-place
until version 8.0 (currently in beta). Instead, you need to:
1) Add a new column of the correct length;
2) Copy the data in the old column to the new column;
3) Drop the old column;
4) Rename the new column to the same name as the old column.
I realize that this approach can be quite painful if you have dependant views,
contstraints, etc. It's why we fixed it for 8.0. You can also:
1) pg_dump the database in text format;
2) edit the table definition in the pg_dump file;
3) re-load the database
While it *is* possible to change the column size by updating the system
tables, doing so is NOT recommended as it can cause unexpected database
errors.
--
Josh Berkus
Aglio Database Solutions
San Francisco
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2004-09-01 16:32 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-01 06:42 Changing the column length Michael Ryan S. Puncia <mpuncia@census.gov.ph>
2004-09-01 08:47 ` gnari <gnari@simnet.is>
2004-09-01 16:32 ` Josh Berkus <josh@agliodbs.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