Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread SQL Manual, documentation of NULL
Thu, Mar 22 2007 1:30 PMPermanent Link

"Ole Willy Tuv"
Tim,

From the SQL Manual:

<quote>
Definition of a NULL

NULL is the term used in the SQL standard and database management systems to
describe a value that is not known.  It is important to distinguish that
while a NULL is an unknown value, it does still have a type.  There is no
such thing as a unknown value that also has an unknown type.
</quote>

While the keyword NULL is used in SQL to specify the null value, it's *not*
associated with a data type, except for contextually typed value
specifications. This is why SQL can use a single keyword, instead of
defining a separate null keyword for each supported data type. This is also
why an explicit cast is needed to associate NULL with a data type in value
expressions, for example:

select cast(null as integer) from dummy

Ole Willy Tuv

Thu, Mar 22 2007 5:44 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ole,

<< While the keyword NULL is used in SQL to specify the null value, it's
*not* associated with a data type, except for contextually typed value
specifications. This is why SQL can use a single keyword, instead of
defining a separate null keyword for each supported data type. This is also
why an explicit cast is needed to associate NULL with a data ype in value
expressions, for example: >>

The paragraph was in reference to column values, not the NULL constant,
which is the only exception where a NULL value also has an unknown type.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Mar 22 2007 5:56 PMPermanent Link

"Ole Willy Tuv"
Tim,

<< The paragraph was in reference to column values, not the NULL constant,
which is the only exception where a NULL value also has an unknown type. >>

Yes, but the statement that a value denoted by the NULL keyword always has a
data type is confusing, particularly since the opposite is true.

Well, it was just a comment. You're the author of the EDB SQL Manual Smile

Ole Willy Tuv

Fri, Mar 23 2007 7:13 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ole,

<< Yes, but the statement that a value denoted by the NULL keyword always
has a data type is confusing, particularly since the opposite is true. >>

I'll make a note to add the word "column" to the description.

--
Tim Young
Elevate Software
www.elevatesoft.com

Sun, Mar 25 2007 8:49 AMPermanent Link

"Ole Willy Tuv"
Tim,

<< I'll make a note to add the word "column" to the description. >>

Something like the following text might be a more precise documentation of
NULL:

Definition of the NULL keyword

NULL is the term used in the SQL standard and database management systems to
describe a value that is not known. It is important to be aware of that the
keyword NULL in SQL text does not associate a data type with the null value,
except when specified as a contextually typed value specification, where the
data type is implicitly derived from the context of the assignment. An
explicit cast is needed in general value expressions to associate NULL with
a data type.

Examples

NULL as a value expression:

SELECT CAST(NULL AS INTEGER) AS null_expression
FROM <table name>

NULL as contextually typed value specifications:

INSERT INTO <table name> (<column name>) VALUES (NULL);

UPDATE <table name> SET <column name> = NULL;

Ole Willy Tuv

Mon, Mar 26 2007 8:47 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ole,

<< Something like the following text might be a more precise documentation
of NULL: >>

While I appreciate the input, we're trying to stay away from using the
phrasing that the standard uses, mainly because most people won't understand
a word of it.  Case in point - "contextually typed value specification".
Most of the phrasing in the standard requires multiple cross-reference
lookups in order to resolve a simple question, and that is not what we want
our manuals to be like.  It's fine for the standard, because it has to be
completely anal. Smiley

--
Tim Young
Elevate Software
www.elevatesoft.com

Image