Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-09-2013, 11:42 PM   PM User | #1
doubledee
Regular Coder

 
doubledee's Avatar
 
Join Date: Mar 2011
Location: Arizona
Posts: 640
Thanks: 20
Thanked 0 Times in 0 Posts
doubledee has a little shameless behaviour in the past
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
doubledee is offline   Reply With Quote
Old 06-10-2013, 12:07 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is online now   Reply With Quote
Old 06-10-2013, 12:20 AM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is online now   Reply With Quote
Old 06-10-2013, 01:02 AM   PM User | #4
doubledee
Regular Coder

 
doubledee's Avatar
 
Join Date: Mar 2011
Location: Arizona
Posts: 640
Thanks: 20
Thanked 0 Times in 0 Posts
doubledee has a little shameless behaviour in the past
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...


Quote:
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!)


Quote:
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..
doubledee is offline   Reply With Quote
Old 06-10-2013, 01:09 AM   PM User | #5
doubledee
Regular Coder

 
doubledee's Avatar
 
Join Date: Mar 2011
Location: Arizona
Posts: 640
Thanks: 20
Thanked 0 Times in 0 Posts
doubledee has a little shameless behaviour in the past
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
doubledee is offline   Reply With Quote
Old 06-10-2013, 02:41 AM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
(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.
Old Pedant is online now   Reply With Quote
Old 06-10-2013, 03:38 PM   PM User | #7
doubledee
Regular Coder

 
doubledee's Avatar
 
Join Date: Mar 2011
Location: Arizona
Posts: 640
Thanks: 20
Thanked 0 Times in 0 Posts
doubledee has a little shameless behaviour in the past
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
doubledee is offline   Reply With Quote
Old 06-10-2013, 03:48 PM   PM User | #8
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,757
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
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.
FishMonger is offline   Reply With Quote
Old 06-10-2013, 04:05 PM   PM User | #9
doubledee
Regular Coder

 
doubledee's Avatar
 
Join Date: Mar 2011
Location: Arizona
Posts: 640
Thanks: 20
Thanked 0 Times in 0 Posts
doubledee has a little shameless behaviour in the past
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
doubledee is offline   Reply With Quote
Old 06-10-2013, 07:18 PM   PM User | #10
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:47 AM.


Advertisement
Log in to turn off these ads.