A NULL in a column means that the user or application has made no entry in that column. That is, a data value for the column is unknown or not available.
NULL does not mean the same as zero (numerical values) or blank (character values). Rather, NULL values allow you to distinguish between a deliberate entry of zero for numeric columns or blank for character columns and a non-entry, which is NULL for both numeric and character columns.
NULL can be entered only where NULL values are permitted for the column. Whether a column can accept NULL values is determined when the table is created. Assuming a column can accept NULL values, NULL is inserted:
Default If no data is entered, and the column has no other default setting.
Explicit entry You can explicitly insert the word NULL without quotation marks. If the word NULL is typed in a character column with quotation marks, it is treated as data, not as the NULL value.
For example, the DepartmentHeadID column of the Departments table allows NULL values. You can enter two rows for departments with no manager as follows:
INSERT INTO Departments (DepartmentID, DepartmentName) VALUES (201, 'Eastern Sales') INSERT INTO Departments VALUES (202, 'Western Sales', null); |
NULL values are returned to the client application for display, just as with other values. For example, the following example illustrates how NULL values are displayed in Interactive SQL:
SELECT * FROM Departments; |
DepartmentID | DepartmentName | DepartmentHeadID |
---|---|---|
100 | R & D | 501 |
200 | Sales | 904 |
300 | Finance | 1293 |
400 | Marketing | 1576 |
500 | Shipping | 703 |
201 | Eastern Sales | (null) |
202 | Western Sales | (null) |
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |