Re: "IS NOT NULL" != "NOT NULL"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vince Vielhaber <vev(at)michvhf(dot)com>
Cc: Sean Chittenden <sean(at)chittenden(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: "IS NOT NULL" != "NOT NULL"
Date: 2002-01-19 23:09:31
Message-ID: 23413.1011481771@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vince Vielhaber <vev(at)michvhf(dot)com> writes:
> I had a hell of a time with that at first too. What you need to
> understand is that NULL isn't necessarily empty as you would expect.
> It's not the same as a null string - a null string actually has a
> real definition, a zero length string. I probably didn't help much.

Right. The common phrase "null string" doesn't help to reduce the
confusion any; perhaps "empty string" for zero-length string would
be a better phrase to use when you are working with SQL. NULL is
absolutely not the same as an empty string. NULL is outside the
domain of normal data for every datatype; it is better thought of
as the absence of a value than as any particular value.

I've been told that Oracle fails to distinguish empty strings from
NULL, which if true is a clear violation of the SQL specification.
If you're used to Oracle then that might help explain your confusion :-(

Another problem is that SQL's boolean operations act as though NULL
is the logical value UNKNOWN, rather than explicitly setting up a
boolean datatype with the three allowed values TRUE, FALSE, UNKNOWN.
While the rules for propagation of NULL happen to be similar to the
results that logic dictates you get for UNKNOWN, this is still a kind
of type pun, and it doesn't help to reduce the confusion any.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-01-19 23:22:08 Re: Clarification question
Previous Message Vince Vielhaber 2002-01-19 22:58:06 Re: "IS NOT NULL" != "NOT NULL"