Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle drop column and unused column

Tags:

oracle

I have one table named test which has 3 columns:

  1. Name
  2. id
  3. address

After some time I know one column is not in use. I want to drop one column, let's say id .

Oracle has one feature to identify a column as unused. What is differenc between drop column vs set unused column?

like image 837
Santosh Chaurasia Avatar asked Jul 05 '12 19:07

Santosh Chaurasia


3 Answers

When you drop a column it moves into recycle bin while when you mark a column unused it is like logically dropping it but physically preserving it.

Sometimes marking a column as unused and then using the alter table name drop unused column statement is useful because it allows the DBA to take away column access quickly and immediately. Later on, during a routine database maintenance weekend or after business hours, you can then remove the column with the alter table name drop unused column to reclaim the space.

On the other hand, marking the column unused won't free up any space and when there is an need to free up space and remove the columns that are not needed you would be better off dropping it.

like image 77
JUG Avatar answered Oct 24 '22 00:10

JUG


It's a matter of convenience, actually...

see here

setting to "unused" is just like dropping, but will allow you to defer the actual physical deletion to a later date.

like image 23
p.marino Avatar answered Oct 24 '22 00:10

p.marino


This is a help to DBA's maintenance window not for your use in general. For developer it means DROP column. that's it, no recovery later point. instead if you are in 12 c then use INVISIBLE option.

like image 1
Sachi Avatar answered Oct 24 '22 01:10

Sachi