How can I alter a column whose restricted to NOT NULL to accept NULL values?
Asked
Active
Viewed 2.2k times
4 Answers
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
-
-
not in mysql. in other dbms, such as oracle, it will not allow you alter a nonempty column, but mysql automagically casts things around for you when you alter columns. – regality Apr 18 '11 at 19:02
-
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
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