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.
Answers
You want the following:
ALTER TABLE mytable MODIFY mycolumn VARCHAR(255);
Columns are nullable by default. As long as the column is not declared
UNIQUE
or NOT NULL
, there shouldn't be any problems.
My solution:
ALTER TABLE table_name CHANGE column_name column_name type DEFAULT NULL
For example:
ALTER TABLE SCHEDULE CHANGE date date DATETIME DEFAULT NULL;
Use:
ALTER TABLE mytable MODIFY mycolumn VARCHAR(255);
0 comments:
Post a Comment