From jkanter@virginia.edu Wed Jan 23 19:53:53 2002 Received: from mail.virginia.edu (mail.Virginia.EDU [128.143.2.9]) by postgresql.org (8.11.3/8.11.4) with SMTP id g0NJrql94218 for ; Wed, 23 Jan 2002 14:53:53 -0500 (EST) (envelope-from jkanter@virginia.edu) Received: from smtp.mail.virginia.edu by mail.virginia.edu id aa01510; 23 Jan 2002 14:52 EST Received: from jlk3xpc (d-128-19-222.bootp.Virginia.EDU [128.143.19.222]) by smtp.mail.Virginia.EDU (8.9.3/8.9.3) with SMTP id OAA12426 for ; Wed, 23 Jan 2002 14:52:29 -0500 Message-ID: <008401c1a447$cd0402f0$de138f80@virginia.edu> From: Jodi Kanter To: Postgres Admin List Subject: drop column? Date: Wed, 23 Jan 2002 14:54:43 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0081_01C1A41D.E410FD10" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200201/150 X-Sequence-Number: 3037 This is a multi-part message in MIME format. ------=_NextPart_000_0081_01C1A41D.E410FD10 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I cannot seem to locate any documentation about removing a column that I ju= st added to a table. There is no data in that particular column but there i= s in the rest of the table. Can I remove this column or will I need to drop the entire table and restor= e from backup? Thanks Jodi _______________________________ Jodi L Kanter BioInformatics Database Administrator University of Virginia (434) 924-2846 jkanter@virginia.edu =20 =20 =20 ------=_NextPart_000_0081_01C1A41D.E410FD10 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I cannot seem to locate any documentation about removing a column that= I=20 just added to a table. There is no data in that particular column but there= is=20 in the rest of the table.
Can I remove this column or will I need to drop the entire table and= =20 restore from backup?
Thanks
Jodi

_______________________________
Jodi=20 L Kanter
BioInformatics Database Administrator
University of=20 Virginia
(434) 924-2846
jkanter@virginia.edu

 

 

 

<= /DIV> ------=_NextPart_000_0081_01C1A41D.E410FD10-- From nickf@ontko.com Wed Jan 23 20:29:57 2002 Received: from swan.prod.itd.earthlink.net (swan.mail.pas.earthlink.net [207.217.120.123]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0NKTvl05850 for ; Wed, 23 Jan 2002 15:29:57 -0500 (EST) (envelope-from nickf@ontko.com) Received: from 1cust174.tnt1.richmond.in.da.uu.net ([63.27.103.174] helo=nick) by swan.prod.itd.earthlink.net with smtp (Exim 3.33 #1) id 16TU1t-00039n-00; Wed, 23 Jan 2002 12:29:57 -0800 Reply-To: From: "Nick Fankhauser" To: "Jodi Kanter" , "Postgres Admin List" Subject: Re: drop column? Date: Wed, 23 Jan 2002 15:25:59 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Importance: Normal In-Reply-To: <008401c1a447$cd0402f0$de138f80@virginia.edu> X-Archive-Number: 200201/152 X-Sequence-Number: 3039 >Can I remove this column or will I need to drop the entire table and restore from backup? There's not a "remove column" option for alter table, but you may be able to get around restoring by renaming the existing table, creating a replacement the way you want it to look, & then copy from the old to new using "insert into table newtable (col1,col2) values (select col1,col2 from oldtable);" -Nick -------------------------------------------------------------------------- Nick Fankhauser nickf@ontko.com Phone 1.765.935.4283 Fax 1.765.962.9788 Ray Ontko & Co. Software Consulting Services http://www.ontko.com/ From pgsql@c0de.net Wed Jan 23 20:29:07 2002 Received: from home.c0de.net (209.dsl6660135.nokia.surewest.net [66.60.135.209]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0NKT7l05764 for ; Wed, 23 Jan 2002 15:29:07 -0500 (EST) (envelope-from phill@home.c0de.net) Received: from phill by home.c0de.net with local (Exim 3.34 #1 (Debian)) id 16TU13-0004z0-00; Wed, 23 Jan 2002 12:29:05 -0800 Date: Wed, 23 Jan 2002 12:29:05 -0800 From: Phill Kenoyer To: Jodi Kanter Cc: Postgres Admin List Subject: Re: drop column? Message-ID: <20020123202905.GB16670@home.c0de.net> References: <008401c1a447$cd0402f0$de138f80@virginia.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <008401c1a447$cd0402f0$de138f80@virginia.edu> User-Agent: Mutt/1.3.26i X-Archive-Number: 200201/151 X-Sequence-Number: 3038 This is something I have been wanting for a long time. The ability to update or drop a column from a table. Right now you have to select the columns you want into a temp table and drop the working table and rename the temp table to the working table. |On 020123 12:15 |Jodi Kanter (jkanter@virginia.edu) wrote the following... | |I cannot seem to locate any documentation about removing a column that I just added to a table. There is no data in that particular column but there is in the rest of the table. |Can I remove this column or will I need to drop the entire table and restore from backup? |Thanks |Jodi |_______________________________ |Jodi L Kanter |BioInformatics Database Administrator |University of Virginia |(434) 924-2846 |jkanter@virginia.edu -- BOFH Reason of the day: not properly grounded, please bury computer _ | _ (_()(|('.|)('||.|()|`|( From banghe@baileylink.net Wed Jan 23 20:46:13 2002 Received: from mocha2.baileylink.net (mocha2.baileylink.net [12.152.112.28]) by postgresql.org (8.11.3/8.11.4) with SMTP id g0NKkDl13603 for ; Wed, 23 Jan 2002 15:46:13 -0500 (EST) (envelope-from banghe@baileylink.net) Received: (qmail 21661 invoked from network); 23 Jan 2002 20:37:08 -0000 Received: from xindu.baileylink.net (HELO baileylink.net) (12.152.112.61) by mocha2.baileylink.net with SMTP; 23 Jan 2002 20:37:08 -0000 Message-ID: <3C4F2071.74B3EC51@baileylink.net> Date: Wed, 23 Jan 2002 14:43:29 -0600 From: bangh X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en,zh-CN,zh,zh-TW,pdf MIME-Version: 1.0 To: Jodi Kanter CC: Postgres Admin List Subject: Re: drop column? References: <008401c1a447$cd0402f0$de138f80@virginia.edu> Content-Type: multipart/alternative; boundary="------------6400460D6F7E895A9DC13BEA" X-Archive-Number: 200201/153 X-Sequence-Number: 3040 --------------6400460D6F7E895A9DC13BEA Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Probably not, but I don't the new version. There are some ways you can do for this prupose. Create a new table in that database without that columns. you can do this very easily: 1. pg_dump -t table_name -s your_dbname > anyname.dump the switch -s means without data, schem only. it is a very simple ascii file and readable 2. using some edit tool to open file anyname.dump and remove the columns you don't want and change the table name as a new one like "table_new" and do: 3. cat anyname.dump | psql your_dbname 4. psql your_db_name psql> insert into table_new select field1, field2, ... from ori_table; psql> drop ori_table; psql> alter table rename table_new ori_table; Then it is done. PS. for safe, dump your entire database first Banghe Jodi Kanter wrote: > I cannot seem to locate any documentation about removing a column that > I just added to a table. There is no data in that particular column > but there is in the rest of the table.Can I remove this column or will > I need to drop the entire table and restore from backup?ThanksJodi > _______________________________ > > > Jodi L Kanter > BioInformatics Database Administrator > University of Virginia > (434) 924-2846 > jkanter@virginia.edu > > "urn:schemas-microsoft-com:office:office" /> > --------------6400460D6F7E895A9DC13BEA Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Probably not, but I don't the new version.

There are some ways you can do for this prupose.

Create a new table in that database without that columns. you can do this very easily:

1. pg_dump -t table_name -s your_dbname > anyname.dump
   the switch -s means without data, schem only. it is a very simple ascii file and readable

2. using some edit tool to open file anyname.dump and remove the columns you don't want and change the table name as a new one like "table_new" and do:

3. cat anyname.dump | psql your_dbname

4. psql your_db_name
psql> insert into table_new select field1, field2, ... from ori_table;
psql> drop ori_table;
psql> alter table rename table_new ori_table;

Then it is done.

PS. for safe, dump your entire database first

Banghe

Jodi Kanter wrote:

I cannot seem to locate any documentation about removing a column that I just added to a table. There is no data in that particular column but there is in the rest of the table.Can I remove this column or will I need to drop the entire table and restore from backup?ThanksJodi
_______________________________


Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

--------------6400460D6F7E895A9DC13BEA-- From slonh@camgsm.com.kh Thu Jan 24 02:23:53 2002 Received: from mailmx.camgsm.com.kh ([203.144.65.11]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0O2Nll07172 for ; Wed, 23 Jan 2002 21:23:53 -0500 (EST) (envelope-from slonh@camgsm.com.kh) Received: from idlonh ([23.0.160.5]) by mailmx.camgsm.com.kh (8.10.2/8.10.2/SuSE Linux 8.10.0-0.3) with SMTP id g0O1wiT02581; Thu, 24 Jan 2002 08:58:44 +0700 X-Authentication-Warning: mailmx.camgsm.com.kh: Host [23.0.160.5] claimed to be idlonh Message-ID: <009901c1a47a$7f88ed50$05a00017@idlonh> From: "lonh SENG" To: "Jodi Kanter" , "Postgres Admin List" References: <008401c1a447$cd0402f0$de138f80@virginia.edu> Subject: Re: drop column? Date: Thu, 24 Jan 2002 08:57:37 +0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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/155 X-Sequence-Number: 3042 Jodi, Of course, we should have 'alter table .... drop column ....' statement. >Can I remove this column or will I need to drop the entire table and restore from backup? You can do as following: select fields_you_want_to_keep into new_table from old_table. Make sure that this statement execute successfully. Then drop the old table and change table name (alter table ... rename to ...). I am a newbie of postgres. lonh ----- Original Message ----- From: Jodi Kanter To: Postgres Admin List Sent: Thursday, January 24, 2002 2:54 AM Subject: [ADMIN] drop column? I cannot seem to locate any documentation about removing a column that I just added to a table. There is no data in that particular column but there is in the rest of the table. Can I remove this column or will I need to drop the entire table and restore from backup? Thanks Jodi _______________________________ Jodi L Kanter BioInformatics Database Administrator University of Virginia (434) 924-2846 jkanter@virginia.edu From bhuvan@symonds.net Tue Dec 30 14:00:27 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 27189D1B465 for ; Tue, 30 Dec 2003 14:00:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 99864-04 for ; Tue, 30 Dec 2003 09:59:40 -0400 (AST) Received: from Gateway.bksys.co.in (unknown [61.3.252.134]) by svr1.postgresql.org (Postfix) with ESMTP id 007A4D1B4A7 for ; Tue, 30 Dec 2003 09:59:35 -0400 (AST) Received: from Intranet.bksys.co.in (mail.bksys.co.in [192.168.1.1]) by Gateway.bksys.co.in (8.11.6/8.11.6) with ESMTP id hBUDxVq24610; Tue, 30 Dec 2003 19:29:31 +0530 Received: from Bhuvan.bksys.co.in (Bhuvan.bksys.co.in [192.168.1.71]) by Intranet.bksys.co.in (8.11.6/8.11.6) with ESMTP id hBUDxVx09102; Tue, 30 Dec 2003 19:29:31 +0530 Subject: Re: drop column From: "A.Bhuvaneswaran" To: Ashok Chauhan Cc: pgsql-admin@postgresql.org In-Reply-To: <1072804035.3479.6.camel@delta.greatindianproducts.com> References: <1072804035.3479.6.camel@delta.greatindianproducts.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-4+c+bDwASjjUbcUqCweK" Message-Id: <1072793069.1687.17.camel@Bhuvan.bksys.co.in> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Tue, 30 Dec 2003 19:34:29 +0530 X-Filter-Version: 1.11.Cvg (Gateway.bksys.co.in) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/342 X-Sequence-Number: 11848 --=-4+c+bDwASjjUbcUqCweK Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > A command for remove the column but it not work > it gives parse error > ALTER TABLE tablename DROP COLUMN fieldname; drop column feature is implemented since 7.3. So, you please check out your version. regards, bhuvaneswaran --=-4+c+bDwASjjUbcUqCweK Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQA/8YXsL2UFujVh8ToRAqhoAJ4/8JnnXmRY8HVqTqE8/rnn/PFBxgCfcHLI QSAE5gdyfCiBUjEJqlLLF5k= =E7hn -----END PGP SIGNATURE----- --=-4+c+bDwASjjUbcUqCweK-- From ashok@kalculate.com Tue Dec 30 11:34:35 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 102BBD1B44A for ; Tue, 30 Dec 2003 11:34:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 85509-03 for ; Tue, 30 Dec 2003 07:33:47 -0400 (AST) Received: from delta.greatindianproducts.com (unknown [61.16.132.195]) by svr1.postgresql.org (Postfix) with ESMTP id C5A79D1B521 for ; Tue, 30 Dec 2003 07:33:25 -0400 (AST) Received: (from ashok@localhost) by delta.greatindianproducts.com (8.11.6/8.11.6) id hBUH7GU04505; Tue, 30 Dec 2003 17:07:16 GMT X-Authentication-Warning: delta.greatindianproducts.com: ashok set sender to ashok@kalculate.com using -f Subject: drop column From: Ashok Chauhan To: pgsql-admin@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.3 (1.0.3-4) Date: 30 Dec 2003 17:07:15 +0000 Message-Id: <1072804035.3479.6.camel@delta.greatindianproducts.com> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/340 X-Sequence-Number: 11846 hello i have a problem to drop a column. on postgresql site (link) http://www.postgresql.org/docs/current/interactive/ddl-alter.html#AEN2124 A command for remove the column but it not work it gives parse error ALTER TABLE tablename DROP COLUMN fieldname; plz. help me Ashok From ashok@kalculate.com Wed Dec 31 06:01:24 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B9B87D1B443 for ; Wed, 31 Dec 2003 06:01:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 38114-04 for ; Wed, 31 Dec 2003 02:00:35 -0400 (AST) Received: from delta.greatindianproducts.com (unknown [61.16.132.195]) by svr1.postgresql.org (Postfix) with ESMTP id E043BD1B446 for ; Wed, 31 Dec 2003 02:00:31 -0400 (AST) Received: (from ashok@localhost) by delta.greatindianproducts.com (8.11.6/8.11.6) id hBVBYRv14419; Wed, 31 Dec 2003 11:34:27 GMT X-Authentication-Warning: delta.greatindianproducts.com: ashok set sender to ashok@kalculate.com using -f Subject: Re: drop column From: Ashok Chauhan To: pgsql-admin@postgresql.org In-Reply-To: <1072793069.1687.17.camel@Bhuvan.bksys.co.in> References: <1072804035.3479.6.camel@delta.greatindianproducts.com> <1072793069.1687.17.camel@Bhuvan.bksys.co.in> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.3 (1.0.3-4) Date: 31 Dec 2003 11:34:26 +0000 Message-Id: <1072870466.14188.2.camel@delta.greatindianproducts.com> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/348 X-Sequence-Number: 11854 On Tue, 2003-12-30 at 14:04, A.Bhuvaneswaran wrote: > > A command for remove the column but it not work > > it gives parse error > > ALTER TABLE tablename DROP COLUMN fieldname; > > drop column feature is implemented since 7.3. So, you please check out > your version. > > regards, > bhuvaneswaran hello thanks for reply. yes i am using 7.2 version. so any other option except drop the table and re-create it. Ashok