3 ms·
You're technically correct (the best kind of correct!) -- it's not inserting NULL. But it is inserting a value it pulled out of its ass, which I posit is actual
by gxti 16y ago
You're technically correct (the best kind of correct!) -- it's not inserting NULL. But it is inserting a value it pulled out of its ass, which I posit is actually worse. For text types it uses the empty string, for numbers it uses 0, etc. It seems to flag this as a "warning" but said warning does not appear in my terminal or in the mysqld logs, so I have no idea what it says.
- ars 16y agoType "show warnings" to see them. I really don't understand why people have such a problem with this (and boy oh boy am I loosing a lot of karma for this opinion). It's not like it forces this on you. First you can turn it off, and second it only happens if you leave out the columns from the insert, don't leave out the columns and you have nothing to worry about. I personally find it quite useful. I set column defaults as needed for real data, but when testing I let MySQL put in empty values - it saves having to type each and every column that I don't care about.
- gfodor 16y agoWhen you add "NOT NULL" to a schema, you should be thinking: "make sure the user specifies a value for this column" not "this column should be defaulted to zero." This is insane. If you want to specify a default, well, specify a default.