I'm trying to change a bunch of columns in my MySQL database to have the NOT NULL constraint using the following:
mysql> ALTER TABLE Jobs CHANGE Date_to_Run Date_to_Run NOT NULL;
I thought that that was how you made such a change but it's giving me a syntax error.
Any ideas on what I'm doing wrong?
EDIT: Here's the error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL' at line 1
Here's what's wrong:
ALTER TABLE Jobs CHANGE Date_to_Run Date_to_Run NOT NULL;
^^^^^^^^^^^ need to specify the data type
^^^^^ it's MODIFY, not CHANGE
Try this:
ALTER TABLE Jobs MODIFY Date_to_Run DATE NOT NULL;
I'm assuming it's type DATE - if not just put in the actual type instead of DATE, then follow it by NOT NULL.
The ALTER TABLE docs are here
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