konfused Posted February 26, 2013 Share Posted February 26, 2013 All the MySQL manuals that I own, or have borrowed, show a NOT NULL default for the user_id. In phpMyAdmin, if I enter NOT NULL for the user_id, an error message will prevent me from saving the table. The error message reads #1067 Invalid default value for user_id. If I select None the table can be saved. The column user_id is auto_increment and the table works fine with None instead of NOT NULL. Would someone explain why this is so? . Link to comment Share on other sites More sharing options...
Jonathon Posted February 26, 2013 Share Posted February 26, 2013 NOT NULL isn't a default. It's saying that the row cannot have a NULL value. Link to comment Share on other sites More sharing options...
konfused Posted February 26, 2013 Author Share Posted February 26, 2013 Thank you for replying so promptly Jonathon but as a newbie I don't understand what you say. Why do all the manuals say "set the column as NOT NULL" but phpMyAdmin will only save when the column is set to None? Link to comment Share on other sites More sharing options...
Jonathon Posted February 26, 2013 Share Posted February 26, 2013 NOT NULL means a row cannot have a null value. In your case user_id means that it updates itself as you have set auto increment. Meaning you can leave that field blank and the DB will do the rest. To clarify the default options in phpmyadmin are None, As defined, NULL, current timestamp. You are looking at two different areas. The NOT NULL field is a check box and not an available option under DEFAULT 1 Link to comment Share on other sites More sharing options...
konfused Posted March 4, 2013 Author Share Posted March 4, 2013 Many thanks Jonathon As you say I was confused about the areas. I now leave the default fields as None and tick a NULL box where necessary and it all makes sense at last.. Link to comment Share on other sites More sharing options...
Recommended Posts