NULL/NOT NULL Constraint
The NULL/NOT NULL constraints are used to indicate whether or not a field can be left blank when records are entered into a table. You can also specify whether or not specific columns for a table may be left blank when a user enters a new record. NULL means no value. When NULL is specified in the creation of a table, it indicates that a field can be left blank when records are entered into a table. NOT NULL indicates that a field cannot be left blank when records are entered into a table.
In the Toys table script, the NOT NULL constraint is used to ensure that the ToyName and Price columns are not left blank when data is entered into the Toys table. The NULL keyword is specified for the Description column, which means this column can be left blank when entering records.
Note: In Microsoft Access, when you do not state NULL or NOT NULL during the creation of a column, it is automatically set to NULL.
In this tutorial:
- Creating Tables and Inserting Records
- Data Definition Language Component
- CREATE TABLE Syntax
- SQL Data Types
- NULL/NOT NULL Constraint
- PRIMARY KEY Constraint
- FOREIGN KEY Constraint
- Adding Constraints to Existing Tables
- Constraint Syntax
- Inserting Records
- Inserting Data without Specifying Column Names