Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
NOT NULL constraint
Summary
7. Summary

Instruction

Okay, it's time to wrap things up! Here's what we learned:

  1. To add a NOT NULL constraint when defining a table, use:
    CREATE TABLE loan_application (
      ...
      amount decimal(10, 2) NOT NULL,
      ...
    );
  2. By default, the columns accept NULLs. You can emphasize this by putting the NULL keyword after column definition:
    description varchar(255) NULL
    Adding the NULL keyword does not change the column definition, it just emphasizes the default behavior.
  3. To add a NOT NULL constraint to an existing table, use:
    ALTER TABLE loan_application
    ALTER COLUMN loan_period_months SET NOT NULL;
  4. To delete a NOT NULL constraint from an existing table, use:
    ALTER TABLE loan_application
    ALTER COLUMN loan_period_months DROP NOT NULL;

Ready for the pop quiz?

Exercise

Click Next exercise to continue.