MySQL - Remove default value for Datetime field

17,203

Solution 1

Yes, you can drop the default using an ALTER TABLE statement like this:

alter table your_table 
  alter column your_column drop default;

Solution 2

To drop the default from multiple datetime columns in a table:

ALTER TABLE your_table 
   ALTER COLUMN columnname1 DROP DEFAULT,
   ALTER COLUMN columnname2 DROP DEFAULT, 
   ALTER COLUMN columnname3 DROP DEFAULT,
   ....
Share:
17,203

Related videos on Youtube

NullReference
Author by

NullReference

Coffee, C# and many things in between.

Updated on September 16, 2022

Comments

  • NullReference
    NullReference over 1 year

    An existing MySQL table has a DateTime field which is not null and having a Default Value set as '0001-00-00 00:00:00'. Is it possible to Alter this table to remove the default value for the DateTime field ?