April 20th, 2009

How do Constraints Work?, NOT NULL (Part 1 of 2)

Posted by admin in P. Table Creation

Let us review:NULL is a marker used when
         the value does not exist,
         the value exists, but we don’t know what the value is,
         the value is out of range, or
         the value is not appropriate for this row.

> Nulls are shown as hyphens in the result of the SELECT statement.

> If a null is returned, it means that there is no value.

> A null is not the same as a zero (0), a blank, or an empty string (”).

> When testing for a specific value in the field, the result can be: TRUE (equal), FALSE (unequal), or UNKNOWN (null).

> If someone talks about a “null value”, that is wrong because null means there is no value.

> In SQL, the keyword NULL represents a null. When setting a column to NULL, do not specify ‘NULL’ between quotes, or the value will be the literal ‘NULL’.

> Nulls don’t belong to any data type and can be inserted into any column that allows nulls.

> The capability of not allowing nulls is established by using the keywords NOT NULL in a CREATE TABLE column definition. This will be covered in the Data Definition Language topic.

> If you don’t specify a NOT NULL constraint, the column will accept nulls by default.

> One extra byte is used in the SQL file for each field that can have a null, whether the field is NULL or not.

Leave a reply

:mrgreen: :neutral: :twisted: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad: