Re: [GENERAL] DELETE COLUMN function - Mailing list pgsql-general

From Chris Bitmead
Subject Re: [GENERAL] DELETE COLUMN function
Date
Msg-id 37401E28.C560650B@bigfoot.com
Whole thread Raw
In response to DELETE COLUMN function  ("Justin Long" <justinlong@strategicnetwork.org>)
List pgsql-general
Justin Long wrote:
>
> Does anyone have any tips as to how I would go about:
>
> 1. deleting a column out of a database
>
> 2. changing the width of a column in the database

Either...
a) do a SELECT INTO another table and rename that table to be the
original one. You lose the old oids, which may or may not worry you.
b) Use the COPY command to dump the columns to a file. Use perl, C or
your favourite tool to remove the column. Recreate the empty table in
the database using the new schema and load back in.

Not ideal I know.

>
> I've looked at the ALTER TABLE function but all it seems to be able to do is
> to add a column and rename a column. I had thought that I could use it to
> create a new column of the width desired, copy the old column into the new,
> and delete the old, then rename the new to the old, but without a delete
> function this isn't possible...
>
> Never retreat. Never surrender. Never cut a deal with a dragon.
> _______________________________________________________________
> Justin Long                   CIO / Site Editor
> 616 Station Square Ct         Network for Strategic Missions
> Chesapeake, VA 23320          977 Centerville Trnpk CSB 317
> JustinLong@xc.org             Va Beach, VA 23463
> Check out our site at:        http://www.strategicnetwork.org

--
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com

pgsql-general by date:

Previous
From: "Justin Long"
Date:
Subject: DELETE COLUMN function
Next
From: jim@reptiles.org (Jim Mercer)
Date:
Subject: detecting locks