Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,092
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Question about Nullable Fields

    If a field is "Nullable", then does it have to contain any value?

    Currently phpMyAdmin is set up to place the word "NULL" in any nullable fields by default, and I don't like that.

    To me, if a field has a value of "NULL", then it should just be blank...

    Sincerely,


    Debbie

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,537
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    Quote Originally Posted by doubledee View Post
    Currently phpMyAdmin is set up to place the word "NULL" in any nullable fields by default, and I don't like that.
    LOL! NO NO NO!

    phpMyAdmin is simply *DETECTING* that the field is null and is REPORTING THAT TO YOU using the word NULL.

    Trust me, if phpMyAdmin was putting "NULL" into a nullable field, MySQL would barf on its feet for any field that wasn't CHAR(4) or VARCHAR(4) or larger!

    How in the world do you think a field declared ad quantity INT NULL could *possibly* contain the *STRING* 'NULL'?? Answer: It sure as heck can't.

    You can easily prove this to yourself by, for example, doing your own SQL query (say in PHP) and then displaying the value of some null field. It will *NOT* be the string NULL.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,537
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    It's true that, with phpMyAdmin, there would be no way to tell the difference in the display of a NULL field and the display of a (say) varchar(8) field that contains the text string 'NULL', but I'm sure that the creator of phpMyAdmin figured (rightly so) that there's pretty darned close to a zero chance that anybody would actually store 'NULL' in a field's value. (Though they maybe reckoned without considering amateurs who don't know the difference.)

    Personally, when I display NULL in a table dump, I do so using a different text color than I use for normal text, which then makes it clear.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,092
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    LOL! NO NO NO!

    phpMyAdmin is simply *DETECTING* that the field is null and is REPORTING THAT TO YOU using the word NULL.

    Trust me, if phpMyAdmin was putting "NULL" into a nullable field, MySQL would barf on its feet for any field that wasn't CHAR(4) or VARCHAR(4) or larger!
    Oh...


    How in the world do you think a field declared ad quantity INT NULL could *possibly* contain the *STRING* 'NULL'?? Answer: It sure as heck can't.
    I guess I never noticed that before. (Good point!)


    You can easily prove this to yourself by, for example, doing your own SQL query (say in PHP) and then displaying the value of some null field. It will *NOT* be the string NULL.
    Okay.


    Debbie
    Last edited by doubledee; 06-10-2013 at 01:04 AM.

  • #5
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,092
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    It's true that, with phpMyAdmin, there would be no way to tell the difference in the display of a NULL field and the display of a (say) varchar(8) field that contains the text string 'NULL', but I'm sure that the creator of phpMyAdmin figured (rightly so) that there's pretty darned close to a zero chance that anybody would actually store 'NULL' in a field's value. (Though they maybe reckoned without considering amateurs who don't know the difference.)
    Now that I know what is going on, actually, the way you can tell that a Null is a Null is that phpMyAdmin shows the "placeholder" as an italicized value like this...

    NULL


    I guess it is still sorta annoying to me, since I have a few tables which contain - by design - a fair amount of Null's, and I'd really rather not see NULL in every instance...

    (Is there any way to turn that feature off?)

    Sincerely,


    Debbie

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,537
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    (Is there any way to turn that feature off?)
    Write your own phpMyAddmin?

    See if other database tools do the same thing?

    MySQLWorkbench, for example?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,092
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Write your own phpMyAddmin?

    See if other database tools do the same thing?

    MySQLWorkbench, for example?
    When I have time - which is never - I hope to install and learn MySQL WorkBench, since it is supposed to be a much more serious tool than phpMyAdmin.

    Maybe it will offer more robust features?

    Thanks for straightening me out on NULL "values"...

    Sincerely,


    Debbie

  • #8
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,874
    Thanks
    2
    Thanked 164 Times in 159 Posts
    You had to take the time to install and learn phpMyAddmin, so why not Workbench. It's very easy and quick to install and the learning curve is almost nill.

    However, you do have another tool already installed and that would be the Mysql CLI.

  • #9
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,092
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by FishMonger View Post
    You had to take the time to install and learn phpMyAddmin, so why not Workbench. It's very easy and quick to install and the learning curve is almost nill.

    However, you do have another tool already installed and that would be the Mysql CLI.
    Well, I use MAMP currently, so "No", there really wasn't any learning curve for me with phpMyAdmin.

    But once I get my website up - God knows when that will happen - I would be interested in migrating to something that at least some other people say is more "mature"...

    In the meantime, phpMyAdmin has been more than sufficient for my basic needs.

    Sincerely,


    Debbie

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,537
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    Quote Originally Posted by FishMonger View Post
    However, you do have another tool already installed and that would be the Mysql CLI.
    Well, true. But the command line interface reports null fields with the NULL keyword, as well, and doesn't even use some color or styling to distinguish between the keyword and a string of the same value. So it would still have been just as confusing.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •