How can a not null constraint be dropped?
Let's say there's a table created as follows:
create table testTable ( colA int not null )
How would you drop the not null constraint? I'm looking for something along the lines of
ALTER TABLE testTable ALTER COLUMN colA DROP NOT NULL;
which is what it would look like if I used PostgreSQL. To my amazement, as far as I've been able to find, the MySQL docs, Google and yes, even Stackoverflow (in spite of dozens or hundreds of NULL-related questions) don't seem to lead towards a single simple SQL statement which will do the job.
Solution 1:
I would try something like this
ALTER TABLE testTable MODIFY COLUMN colA int;
Solution 2:
In MySQL, nullability is a part of the datatype, not a constraint. So:
ALTER TABLE testTable MODIFY COLUMN colA int null;
Solution 3:
The syntax was close its actually:
ALTER TABLE testTable CHANGE colA colA int null;
Solution 4:
Try
ALTER TABLE testTable MODIFY COLUMN columnA int;