Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

CHAPTER 5 Constraints > NOT NULL Constraints

NOT NULL Constraints

A NOT NULL constraint applies to a single column only, as shown in Figure 5-1. It restricts a column by making it mandatory, which means you can’t insert a row without a value in the column. Likewise, you can’t update a mandatory column’s value from something to a null value. Optional columns are nullable or null-allowed. This means you can enter something or nothing, where nothing is a null value. Null values also differ from empty strings in MySQL.

In MySQL, the CREATE TABLE statement lets you assign a NOT NULL column constraint as in-line or out-of-line constraints. Oracle requires that you define NOT NULL constraints in-line. There’s no option to add a NOT NULL constraint as a table constraint in an Oracle CREATE TABLE statement. You can, however, use the ALTER TABLE statement to add a NOT NULL constraint to an existing table’s columns in both Oracle and MySQL databases.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial