1

I am adding the following column to a table and I am surprised it doesn't give an error because there is no default value for the column and there is data in the table. When I executed this, the rows with data got a default value of 0 with STRICT_ALL_TABLES.

Is this expected behavior? I couldn't find it documented anywhere.

ALTER TABLE phppos_receivings ADD COLUMN location_id INT(11) NOT NULL;
3
  • possible duplicate of MySQL add a NOT NULL column Commented Apr 16, 2014 at 23:46
  • This almost answers my question and I am 99% confident in the answer, but the link dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html doesn't explain "implicit default" value for ALTER statements. Commented Apr 16, 2014 at 23:58
  • Yeah, but it does describe the strict behavior only in the context of INSERT/REPLACE/UPDATE. So I assume DDL may behave differently. This is the best I can come up with, so I think it falls into the category of "not documented." Commented Apr 17, 2014 at 1:10

0

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.