Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Defining columns with DEFAULT
Adding DEFAULT to existing tables
Summary
11. Summary

Instruction

Great job. Let's do a quick summary now.

  1. To add a default value when defining a table, use:
    CREATE TABLE card_game (
      ...
      min_players integer DEFAULT 2,
      ...
    );
  2. To link a sequence to a table, use:
    CREATE TABLE board_game (
      id integer DEFAULT nextval('my_sequence') PRIMARY KEY
    );
    or when using the standard SQL syntax:
    CREATE TABLE board_game (
      id integer DEFAULT NEXT VALUE FOR my_sequence PRIMARY KEY
    );
  3. To add a default value to an existing column, use:
    ALTER TABLE therapist
    ALTER COLUMN price SET DEFAULT 60.00;
  4. To remove a default value from an existing column, use:
    ALTER TABLE therapist
    ALTER COLUMN full_name DROP DEFAULT;

How about a pop quiz?

Exercise

Click Next exercise to continue.