Re: How to delete column

From: James Petts <jpetts_at_celltech.co.uk>
Date: 1998/01/15
Message-ID: <34BDD280.3E00_at_celltech.co.uk>#1/1


spadesmania rules wrote:
>
> I accidentally add a column in a table. How do I delete it ?
> Thanks for any help.

The commonest way is to create a temporary table with all columns except the rogue, drop the original table, then rename the temporary table back to the original. Thus:

Assume that the table which has the extra column is called ORIG and has columns COL1, COL2, COL3, COL4 and COL5 and that COL5 is the one you wish to delete

[Quoted] CREATE TABLE TEMP AS SELECT COL1,COL2,COL3,COL4 FROM ORIG); DROP TABLE ORIG; CREATE TABLE ORIG AS SELECT * FROM TEMP; RENAME TEMP TO ORIG; Somebody (I forget who) has written a procedure to delete, but the source is not avaialable, so I can't tell you how he does it.

-- 
James "I'd rather fall off Ilustrada than ride any other horse" Petts
Received on Thu Jan 15 1998 - 00:00:00 CET

Original text of this message