Received: from ms1.nypost.com ([65.209.114.183]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0IFNxV68853 for ; Fri, 18 Jan 2002 10:23:59 -0500 (EST) (envelope-from hjohnson@nypost.com) Received: from NYPOST-EXCHANGE.1211.nypost.com (172.16.1.117) by ms1.nypost.com (Worldmail 1.3.167); 18 Jan 2002 10:24:02 -0500 Received: from SEPHIE ([172.16.11.81]) by NYPOST-EXCHANGE.1211.nypost.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id W75RJ5H4; Fri, 18 Jan 2002 10:19:07 -0500 Message-ID: <00cc01c1a033$c2df39b0$510b10ac@sephie> From: "Heather Johnson" To: "Jodi Kanter" , "Postgres Admin List" References: <00a401c1a030$3dfd0130$de138f80@virginia.edu> Subject: Re: adding fields Date: Fri, 18 Jan 2002 10:21:11 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00C9_01C1A009.DA019090" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200201/119 X-Sequence-Number: 3006 This is a multi-part message in MIME format. ------=_NextPart_000_00C9_01C1A009.DA019090 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Jodi-- No, you shouldn't have to go to that amount of trouble. Try this instead (c= hange the name of the table, the default value, the column name, and the co= lumn 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'; =20 COMMIT WORK;=20 Then you can do: BEGIN WORK; UPDATE table_adding_stuff_to SET new_column_name =3D 'default value'; COMMIT WORK;=20 Heather ----- Original Message -----=20 From: Jodi Kanter=20 To: Postgres Admin List=20 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=20 _______________________________ Jodi L Kanter BioInformatics Database Administrator University of Virginia (434) 924-2846 jkanter@virginia.edu =20=20=20 =20=20=20 =20=20=20 ------=_NextPart_000_00C9_01C1A009.DA019090 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi Jodi--
 
No, you shouldn't have to go to that amoun= t of=20 trouble. Try this instead (change the name of the table, the default value,= the=20 column name, and the column type to suit your needs):
 
BEGIN WORK;
LOCK=20 TABLE table_adding_stuff_to IN ACCESS EXCLUSIVE MODE;
 
ALTER TABLE table_adding_stuff_to ADD COLU= MN=20 new_column_name COLUMNTYPE;
ALTER TABLE table_adding_stuff_to ALTER COLU= MN=20 new_column_name SET DEFAULT 'default value';
 
COMMIT WORK;=20
 
Then you can do:
 
BEGIN WORK;
UPDATE table_adding_stuff_to SET new_colum= n_name =3D=20 'default value';
COMMIT WORK;
 
Heather
----- Original Message -----
Fro= m:=20 Jodi= =20 Kanter
Sent: Friday, January 18, 2002 9:5= 5=20 AM
Subject: [ADMIN] adding fields

I need to add a field to an existing table that contains a good amou= nt of=20 data. Do I need to drop table, recreate, and then reload data to do this?= I=20 cannot seem to find any documentation to say otherwise.
Thanks
Jodi

_______________________________
Jodi=20 L Kanter
BioInformatics Database Administrator
University of=20 Virginia
(434) 924-2846
jkanter@virginia.edu
<= SPAN=20 style=3D"FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt;= mso-fareast-font-family: 'MS Mincho'">

 

 

 

------=_NextPart_000_00C9_01C1A009.DA019090--