pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: bangh <banghe@baileylink.net>
To: Jodi Kanter <jkanter@virginia.edu>
Cc: Postgres Admin List <pgsql-admin@postgresql.org>
Subject: Re: drop column?
Date: Wed, 23 Jan 2002 14:43:29 -0600
Message-ID: <3C4F2071.74B3EC51@baileylink.net> (raw)
References: <008401c1a447$cd0402f0$de138f80@virginia.edu>

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

view thread (8+ messages)  latest in thread

Message-ID: <3C4F2071.74B3EC51@baileylink.net>
Permalink:  ../3C4F2071.74B3EC51@baileylink.net/
Also on:    postgresql.org/message-id/3C4F2071.74B3EC51@baileylink.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: banghe@baileylink.net, jkanter@virginia.edu
  Subject: Re: drop column?
  In-Reply-To: <3C4F2071.74B3EC51@baileylink.net>
  References: <008401c1a447$cd0402f0$de138f80@virginia.edu> <3C4F2071.74B3EC51@baileylink.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox