0

I'm trying to modify a row, marketing_schedule, in my database to change the column to NULL to NO.

enter image description here

I've tried the command ALTER TABLE permissions MODIFY marketing_schedule tinyint(1) NOT NULL; as given in How to add not null constraint to existing column in MySQL5.1 but I get the error shown in the screenshot above. Any idea on why I'm getting this error and how I can go about fixing my problem?

LLBrettK
  • 113
  • 1
  • 10
  • If it's an `INT` column, how can you change its value to `NO`? That's a string, not an integer. – Barmar Jun 25 '18 at 16:59

2 Answers2

2

Update rows which have NULL's in marketing_schedule to have a value and run the ALTER TABLE command again.

slaakso
  • 8,331
  • 2
  • 16
  • 27
1

If your are providing the default not null then you have to provide default value in query

These query run after the update , as answered by @slaakso

ALTER TABLE `table_name` Modify `column_name` TINYINT(4) DEFAULT 1 NOT 
NULL;

OR

 ALTER TABLE `table_name` CHANGE `column_name` `column_name` TINYINT(4) 
 DEFAULT 1 NOT NULL;

Here 1 is default value

Ashwani Tiwari
  • 1,497
  • 18
  • 28