18

How can I alter a column whose restricted to NOT NULL to accept NULL values?

Aufwind
  • 25,310
  • 38
  • 109
  • 154
  • Possible duplicate of [How do I modify a MySQL column to allow NULL?](http://stackoverflow.com/questions/212939/how-do-i-modify-a-mysql-column-to-allow-null) – cellepo Jul 18 '16 at 17:11

4 Answers4

27

just modify it and put in the old type and leave off the not null

alter table table_name modify column foo int;
regality
  • 6,496
  • 6
  • 29
  • 26
1

Assuming the table is table_name, column is column_name and its defined as varchar(200):

alter table table_name modify column column_name varchar(200) default null;
lobster1234
  • 7,679
  • 26
  • 30
1

Try this:

ALTER TABLE mytable MODIFY mycolumn varchar(255) null;
ANisus
  • 74,460
  • 29
  • 162
  • 158
1

You can do this way:

ALTER TABLE tableName MODIFY columnName varchar2(100)

Replace tableName with your table name and columnName with your column name and also varchar2(100) to whatever data type you're using for this column

Naveed Ahmad
  • 3,176
  • 1
  • 15
  • 18