backyard Posted August 21, 2008 Share Posted August 21, 2008 I just want to make sure I understand the NULL column in my database. Is it fair to say if it says No then that means that the entry for that field cannot be null so the cell will be filled with some value even if it's left blank. Also, is there any serious consequences if I change this to NULL? I have a pulldown entry input form and the default choice is blank on the html side even if someone leaves the pulldown in the default position the cell value automatically gets entered with the next value down since it's not null. Also, is there any restrictions on type when you select NULL as the field is currently set to varchar. Thanks Quote Link to comment Share on other sites More sharing options...
AjBaz100 Posted August 21, 2008 Share Posted August 21, 2008 If the column is NULL then you must add a value into the column when you do your insert. However, if you have set a DEFAULT value on table creation, then you don't have to add a value on insert as the default value will be used. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 21, 2008 Share Posted August 21, 2008 If the column is NULL then you must add a value into the column when you do your insert. Not true. Quote Link to comment Share on other sites More sharing options...
Hooker Posted August 22, 2008 Share Posted August 22, 2008 If the column is NULL then you must add a value into the column when you do your insert. However, if you have set a DEFAULT value on table creation, then you don't have to add a value on insert as the default value will be used. To insert a NULL value, just leave the column name from the INSERT statement. Columns have NULL as default unless specified by NOT NULL. You can have null values for integers as well as text or binary data. So, you can insert nothing into a NULL field (although if it's not intentional i'd advise you use PHP or whatever language you're sending the commands to MySQL with to check the input's validity before sending the request) without input and you can also check if a field has a NULL value when selecting. Quote Link to comment Share on other sites More sharing options...
AjBaz100 Posted August 22, 2008 Share Posted August 22, 2008 Apologies, I meant to say 'NOT NULL', instead of NULL. I was in a bit of rush when I answered. Quote Link to comment Share on other sites More sharing options...
Hooker Posted August 22, 2008 Share Posted August 22, 2008 thought so Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.