Is there a command in MySQL to reset a field to its default value? You know, in favor of the "Do Not Repeat Yourself" rule, I don't want to write the (quite long) default value multiple times in code, only once in the DB.
I looked around quite some time in google, found nothing. I'm starting to suspect such command doesn't exist, but nevertheless, if it does, sy here's going to know about it. :)
Set a default valueRight-click the control that you want to change, and then click Properties or press F4. Click the All tab in the property sheet, locate the Default Value property, and then enter your default value. Press CTRL+S to save your changes.
To enforce NOT NULL for a column in MySQL, you use the ALTER TABLE .... MODIFY command and restate the column definition, adding the NOT NULL attribute.
MySQL has a DEFAULT
keyword (and function) that will do exactly what you want.
UPDATE table SET col = DEFAULT WHERE id = 2
OR
UPDATE table SET col = DEFAULT(col2) WHERE id = 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With