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--