首页 > 应用开发 > IT综合 > Nulls Indicate Absence of Value (162)

Nulls Indicate Absence of Value (162)

原创 IT综合 作者:tsinglee 时间:2007-11-08 10:42:06 0 删除 编辑

A null is the absence of a value in a column of a row. Nulls indicate missing,
unknown, or inapplicable data. A null should not be used to imply any other value,
such as zero. A column allows nulls unless a NOT NULL or PRIMARY KEY integrity
constraint has been defined for the column, in which case no row can be inserted
without a value for that column.
Nulls are stored in the database if they fall between columns with data values. In these
cases they require 1 byte to store the length of the column (zero).
Trailing nulls in a row require no storage because a new row header signals that the
remaining columns in the previous row are null. For example, if the last three columns
of a table are null, no information is stored for those columns. In tables with many
columns, the columns more likely to contain nulls should be defined last to conserve
disk space.
Most comparisons between nulls and other values are by definition neither true nor
false, but unknown. To identify nulls in SQL, use the IS NULL predicate. Use the SQL
function NVL to convert nulls to non-null values.
Nulls are not indexed, except when the cluster key column value is null or the index is
a bitmap index.

1. 空值表示一行的某列无值 . 空值的含义是数据缺失 , 未知 ,或N/A .空值不等同于其他任何值,如0 .
2. 当一个空值在一行中位于有数据值的两列之间时 , 此列在数据库中需要占用 1 字节的空间来存储其列长(0).
3. 而当一个空值位于行尾时无需占用存储空间 , 因为新一行的行头就标志着前一行未存储的字段均为空 .
4. Oracle 中规定空值和其他任何值的比较结果既非真也非假 , 而是未知 . 如需在 SQL 中判断空值 , 应该使用谓词IS NULL .
用户可以使用 SQL 函数 NVL 将空值转换为非空值.
5. 空值不会被加入索引 , 但有两种情况例外:其一是为空值的列属于簇键,其二是索引为位图索引


来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

  • 博文量
  • 访问量