ASA SQL User's Guide
Queries: Selecting Data from a Table
The WHERE clause: specifying rows
A NULL in a column means that the user or application has made no entry in that column. 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 in a column where NULL values are permitted, as specified in the create table statement, in two ways:
Default If no data is entered, and the column has no other default setting, NULL is entered.
Explicit entry You can explicitly enter the value NULL by typing 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 a null value.
For example, the dept_head_id column of the department table allows nulls. You can enter two rows for departments with no manager as follows:
INSERT INTO department (dept_id, dept_name) VALUES (201, 'Eastern Sales') INSERT INTO department VALUES (202, 'Western Sales', null)
When NULLS are retrieved, displays of query results in Interactive SQL show (NULL) in the appropriate position:
SELECT * FROM department
dept_id | dept_name | dept_head_id |
---|---|---|
100 | R & D | 501 |
200 | Sales | 904 |
300 | Finance | 1293 |
400 | Marketing | 1576 |
500 | Shipping | 703 |
201 | Eastern Sales | (NULL) |
202 | Western Sales | (NULL) |
Testing a column for NULL
Properties of NULL