How do I delete a column from an existing table?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The command you’re looking for is:
where
tblNameis the name of the table andcolumnNameis the name of the column, but there’s a few things you may need to do first.Keep in mind that the performance of this command may not necessarily be good. One option is to wait for a down-time period when you can be certain no-one will be accessing the database, rename the current table, then use
create tableandinsert into ... select fromto transfer the columns you don’t want deleted.One of the later releases of Oracle actually has a soft delete which can just marks a column as unused without removing it physically. It has the same effect since you can no longer reference it and there’s a command along the lines of
alter table ... drop unused columnswhich is meant to be run in quiet time, which does the hard work of actually removing it physically.This has the advantage of “disappearing” the columns immediately without dragging down database performance during busy times.