Mysql Tech Byte:
We can remove just the default values of a column(s) in Mysql using the following command.
Single Column:
ALTER TABLE < TableName > ALTER < ColumnName > DROP DEFAULT;
If we execute the above statement, the default value for that particular column will be dropped.
Multiple Columns:
ALTER TABLE < TableName > ALTER < ColumnName1 > DROP DEFAULT, ALTER < ColumnName2 > DROP DEFAULT;
Modify a default value:
ALTER TABLE < TableName > ALTER < ColumnName1 > DROP DEFAULT, ALTER < ColumnName2 > SET DEFAULT 100;
This statement removes a default value for ColumnName1 and alters the DEFAULT value of ColumnName2 from its previous value to the new value 100.
We can remove just the default values of a column(s) in Mysql using the following command.
Single Column:
ALTER TABLE < TableName > ALTER < ColumnName > DROP DEFAULT;
If we execute the above statement, the default value for that particular column will be dropped.
Multiple Columns:
ALTER TABLE < TableName > ALTER < ColumnName1 > DROP DEFAULT, ALTER < ColumnName2 > DROP DEFAULT;
Modify a default value:
ALTER TABLE < TableName > ALTER < ColumnName1 > DROP DEFAULT, ALTER < ColumnName2 > SET DEFAULT 100;
This statement removes a default value for ColumnName1 and alters the DEFAULT value of ColumnName2 from its previous value to the new value 100.
No comments:
Post a Comment