How to Remove Default Value of Column in MySQL

Default constraint allows you to automatically set default values for MySQL columns, when new rows are created in a table. However, sometimes you may need to remove default constraint or drop default value in MySQL. In this article, we will look at how to remove default value of column in MySQL.


How to Remove Default Value of Column in MySQL

It is very easy to remove default constraint in MySQL. We will use ALTER TABLE statement with DROP DEFAULT clause to remove default value of column in MySQL.

Here is the syntax to drop default constraint in MySQL

mysql> ALTER TABLE table_name           
       ALTER column_name DROP DEFAULT;

In the above query, you need to specify the table name and column name for which you want to remove default value.

Also read : How to Add Default Constraint in MySQL

Here is an example to remove default constraint

mysql> ALTER TABLE sample_data        
       ALTER order_date DROP DEFAULT; 

Need a reporting tool for MySQL? Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!

mm

About Ubiq

Ubiq is a dashboard & reporting platform for small & medium businesses. Build dashboards, charts & reports for your business in minutes. Try it for free today!