From: | "Heather Johnson" <hjohnson(at)nypost(dot)com> |
---|---|
To: | "Jodi Kanter" <jkanter(at)virginia(dot)edu>, "Postgres Admin List" <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: adding fields |
Date: | 2002-01-18 15:21:11 |
Message-ID: | 00cc01c1a033$c2df39b0$510b10ac@sephie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Hi Jodi--
No, you shouldn't have to go to that amount of trouble. Try this instead (change the name of the table, the default value, the column name, and the column type to suit your needs):
BEGIN WORK;
LOCK TABLE table_adding_stuff_to IN ACCESS EXCLUSIVE MODE;
ALTER TABLE table_adding_stuff_to ADD COLUMN new_column_name COLUMNTYPE;
ALTER TABLE table_adding_stuff_to ALTER COLUMN new_column_name SET DEFAULT 'default value';
COMMIT WORK;
Then you can do:
BEGIN WORK;
UPDATE table_adding_stuff_to SET new_column_name = 'default value';
COMMIT WORK;
Heather
----- Original Message -----
From: Jodi Kanter
To: Postgres Admin List
Sent: Friday, January 18, 2002 9:55 AM
Subject: [ADMIN] adding fields
I need to add a field to an existing table that contains a good amount of data. Do I need to drop table, recreate, and then reload data to do this? I cannot seem to find any documentation to say otherwise.
Thanks
Jodi
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter(at)virginia(dot)edu
From | Date | Subject | |
---|---|---|---|
Next Message | Esger Abbink | 2002-01-18 15:35:03 | problem concerning vacuum/statistics & query performance |
Previous Message | Jodi Kanter | 2002-01-18 15:20:13 | Re: adding fields |