Dude, I just realized that MySQL's handling of default values sucks. A query I was writing kept failing and I didn't see what was wrong, so I took the query down to just one field. It succeeded, even though I hadn't specified values for NOT NULL fields. So I checked in phpMyAdmin, and it turns out a bunch of default values were set. I figured phpMyAdmin had set them without me telling it to.
So I took a dump of the SQL to create the table, took all the default values out, renamed the original table, and ran that SQL to recreate the table.
I ran the query with just one field again, and it succeeded! So, I got out my MySQL book, looked up "Default" in the index, turned to page 239, and found this in the section on the CREATE statement:
DEFAULT value
This attribute assigns a default value to a field. If a row is inserted into the table without a value for this field, this value will be inserted. If a default is not defined, a null value is inserted unless the field is defined as NOT NULL in which case MySQL picks a value based on the type of the field. (emphasis mine)
That's ridiculous!
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):