Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete columns in oracle?

Status
Not open for further replies.

Fumac

Programmer
Jan 2, 2001
16
0
0
SE
Is there any one who knows if there is any possibility to delete columns in oracle8? Or if one can change a column name?

Thank you for any answer

/Fumac
 
Try...

Modify Table table_name Drop column_name

I have a feeling that the column may need to be null for all rows first. Not sure though.

HTH,

Mike.

 
Thank you Mike, I´ll try it.

/Fumac
 
The ease of doing this depends on which version of Oracle 8 you are running. Oracle 8.0.x doesn't support the drop column command, so you will have to drop and recreate the table in order to eliminate the column(s).

If you have Oracle 8i you can do this more easily. The syntax of the command is

alter table table_name drop column column_name;

You don't have to set the column values to null first.

You should also be aware that you may inadvertently drop other things, such as indexes, that are defined on the column being dropped. If you have a multi column index that includes the dropped column, you will lose the entire index, even though it's very possible that you might prefer to redefine the index with all remaining columns after the drop. If this is the situation you will have to recreate the index from script.
 
I´m running Oracle 8.0, so the only way would be to recreate the table then...hmmm

Thank you for your respons!

/Fumac
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top