MySQL 5.0.45
What is the syntax to alter a table to allow a column to be null, alternately what's wrong with this:
ALTER mytable MODIFY mycolumn varchar(255) null;
I interpreted the manual as just run the above and it would recreate the column, this time allowing null. The server is telling me I have syntactical errors. I just don't see them.
You want the following:
Columns are nullable by default. As long as the column is not declared
UNIQUE
orNOT NULL
, there shouldn't be any problems.Under some circumstances (if you get "ERROR 1064 (42000): You have an error in your SQL syntax;...") you need to do
My solution is the same as @Krishnrohit:
I actually had the column set as
NOT NULL
but with the above query it was changed toNULL
.P.S. I know this an old thread but nobody seems to acknowledge that
CHANGE
is also correct.Your syntax error is caused by a missing "table" in the query
If the column is a double
My solution:
For example: