Re: drop column?

From: bangh <banghe(at)baileylink(dot)net>
To: Jodi Kanter <jkanter(at)virginia(dot)edu>
Cc: Postgres Admin List <pgsql-admin(at)postgresql(dot)org>
Subject: Re: drop column?
Date: 2002-01-23 20:43:29
Message-ID: 3C4F2071.74B3EC51@baileylink.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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(at)virginia(dot)edu
>
> <?xml:namespace prefix = o ns =
> "urn:schemas-microsoft-com:office:office" />
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Zhang, Anna 2002-01-23 21:24:30 timing a process
Previous Message Phill Kenoyer 2002-01-23 20:29:05 Re: drop column?