Alter SQL table - allow NULL column value

Klausos Klausos picture Klausos Klausos · May 15, 2012 · Viewed 112.2k times · Source

Initially, the table "MyTable" has been defined in the following way:

CREATE TABLE IF NOT EXISTS `MyTable` (
  `Col1` smallint(6) NOT NULL AUTO_INCREMENT,
  `Col2` smallint(6) DEFAULT NULL,
  `Col3` varchar(20) NOT NULL,
);

How to update it in such a way that the column "Col 3" would be allowed to be NULL?

Answer

eggyal picture eggyal · May 15, 2012
ALTER TABLE MyTable MODIFY Col3 varchar(20) NULL;