Home

Assistance with Data Entry: The Nullity of a Field

 

Description

During data entry, users of a database face fields that expect data. Sometimes, data will not be available for a particular field. A field is referred to as null when no data entry has been made to it. A field is referred to as null if there is no way of determining the value of its content.

If creating a table, to specify that it can allow null values, type NULL on the right side of the column. Here is an example:

SQL> CREATE TABLE Employees
  2  (
  3     FirstName nvarchar2(20) NULL
  4  );

Table created.

SQL>

To specify that the values of the column are required, on the right side, type NOT NULL. Here is an example:

SQL> CREATE TABLE Employees
  2  (
  3     EmployeeNumber nchar(6) NOT NULL,
  4     FirstName nvarchar2(20) NULL,
  5     LastName nvarchar2(20) NOT NULL
  4  );

Table created.

SQL>

If you don't specify NULL or NOT NULL, the column will be created as NULL. Here is an example:

SQL> CREATE TABLE Employees
  2  (
  3     EmployeeNumber nchar(6) NOT NULL,
  4     FirstName nvarchar2(20) NULL,
  5     LastName nvarchar2(20) NOT NULL,
  6     HourlySalary number
  7  );

Table created.

SQL>
 

 

     
 

Home Copyright © 2009-2010 FunctionX, Inc.