Skip site navigation (1) Skip section navigation (2)

Re: delete column

From: wsheldah(at)lexmark(dot)com
To: webmaster <webmaster(at)harbornet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: delete column
Date: 2002-04-26 20:54:25
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general

1. Back up your database.
2. Use pg_dump to save the schema and data for that table to a text file
3. Edit the file to add a DROP TABLE statement before the CREATE TABLE
and edit the CREATE TABLE statement to omit the column you want to drop.
4. Make sure your data is in the file and is intact.
5. Use psql to execute the commands in the file you just edited.

You'll also want to take steps to be sure no one attempts to update the table
between the time you dump it and the time it finishes restoring.

You may also want to take a look at the TODO list on the postgresql website and
estimate how long it may be before support for DROP COLUMN is added, and support
for ALTER COLUMN improves. Personally, I haven't had a problem with this
procedure, but my dataset is relatively small and I've incurred very little
downtime the few times I've had to do this.

Wes Sheldahl

webmaster <webmaster%harbornet(dot)com(at)interlock(dot)lexmark(dot)com> on 04/26/2002 08:50:53

To:   pgsql-general%postgresql(dot)org(at)interlock(dot)lexmark(dot)com
cc:    (bcc: Wesley Sheldahl/Lex/Lexmark)
Subject:  [GENERAL] delete column

I know this is an easy question, but I can't find any info on how do
this in the PostgreSQL book.  How do you delete a column?  I've been
able to delete tables, db's, rows, etc.  But can't figure out how to
just delete a column.  I'm running RedHat 7.2 and PostgreSQL 7.1

Thanks for any help.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

pgsql-general by date

Next:From: Bruce MomjianDate: 2002-04-26 20:58:02
Subject: Re: delete column
Previous:From: Hillensbeck, PrestonDate: 2002-04-26 20:49:49
Subject: Re: delete column

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group