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?

1
  • If it's an INT column, how can you change its value to NO? That's a string, not an integer. Commented Jun 25, 2018 at 16:59

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.