Null; Using Null Versus Default Values; Defining Columns That Allow Or Prohibit Null; Null In Distinct, Group By, And Order By Clauses - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

Null

Null is a special symbol, independent of data type, that represents an unknown. The Neoview
SQL keyword NULL represents null. Null indicates that an item has no value. For sorting
purposes, null is greater than all other values. You cannot store null in a column by using INSERT
or UPDATE, unless the column allows null.
A column that allows null can be null at any row position. A nullable column has extra bytes
associated with it in each row. A special value stored in these bytes indicates that the column
has null for that row.

Using Null Versus Default Values

There are various scenarios in which a row in a table might contain no value for a specific column.
For example:
A database of telemarketing contacts might have null AGE fields if contacts did not provide
their age.
An order record might have a DATE_SHIPPED column empty until the order is actually
shipped.
An employee record for an international employee might not have a social security number.
You allow null in a column when you want to convey that a value in the column is unknown
(such as the age of a telemarketing contact) or not applicable (such as the social security number
of an international employee).
In deciding whether to allow nulls or use defaults, also note:
Nulls are not the same as blanks. Two blanks can be compared and found equal, while the
result of a comparison of two nulls is indeterminate.
Nulls are not the same as zeros. Zeros can participate in arithmetic operations, while nulls
are excluded from any arithmetic operation.

Defining Columns That Allow or Prohibit Null

The CREATE TABLE and ALTER TABLE statements define the attributes for columns within
tables. A column allows nulls unless the column definition includes the NOT NULL clause or
the column is part of the primary key of the table.
Null is the default for a column (other than NOT NULL) unless the column definition includes
a DEFAULT clause (other than DEFAULT NULL) or the NO DEFAULT clause. The default value
for a column is the value Neoview SQL inserts in a row when an INSERT statement omits a value
for a particular column.

Null in DISTINCT, GROUP BY, and ORDER BY Clauses

In evaluating the DISTINCT, GROUP BY, and ORDER BY clauses, Neoview SQL considers all
nulls to be equal. Additional considerations for these clauses are:
DISTINCT
GROUP BY
ORDER BY
230
SQL Language Elements
Nulls are considered duplicates; therefore, a result has at
most one null.
The result has at most one null group.
Nulls are considered greater than nonnull values.

Advertisement

Table of Contents
loading

Table of Contents