1

I have a table in which one of the column is set default to 0000 and the data type of of the column is number. I want to remove the default value and when a record is saved null should save on this column.

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
user1015388
  • 1,283
  • 4
  • 25
  • 45

2 Answers2

5

You could override default to NULL:

ALTER TABLE tab_name MODIFY col_name DEFAULT NULL;

db<>fiddle demo


If columns was set as NOT NULL then:

ALTER TABLE tab_name MODIFY col_name type_name DEFAULT NULL NULL;

db<>fiddle demo2

Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275
0

First, update current records:

update tab set col=null where col=0;

Then remove default value:

alter tab modify col default null;
fiveelements
  • 3,649
  • 1
  • 17
  • 16