How do I drop 'NOT NULL' from a column in MySQL?

Will picture Will · Jun 8, 2010 · Viewed 29.4k times · Source

A show create table command shows the following:

'columnA' varchar(6) NOT NULL DEFAULT '';

How do I modify that column so that the not null is removed? I need it to be:

'columnA' varchar(6) DEFAULT NULL;

I thought the following would work, but it has no effect:

ALTER TABLE tbl_name MODIFY columnA varchar(6) DEFAULT NULL;

Answer

Eric Petroelje picture Eric Petroelje · Jun 8, 2010

Try this instead:

ALTER TABLE tbl_name MODIFY columnA varchar(6) NULL DEFAULT NULL;