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
10. Removing a default value from an existing column
Summary

Instruction

Perfect! On the other hand, we can also get rid of a default value. Our table definition looks the same now:

CREATE TABLE therapist (
  id integer PRIMARY KEY,
  full_name varchar(32) DEFAULT 'anonymous',
  price decimal(5, 2),
  location varchar(32) DEFAULT 'unknown'
);

Let's say we want to get rid of the default value for full_name:

ALTER TABLE therapist
ALTER COLUMN full_name DROP DEFAULT;

The code above removes the default value from the full_name column. Note that we don't need to know what the default value is – we simply tell the database to DROP DEFAULT.

Exercise

You are again given the same table, desk:

CREATE TABLE desk (
  id integer PRIMARY KEY,
  model_name varchar(32),
  price decimal(6, 2) DEFAULT 304.91,
  is_customizable boolean
);

Your task now is to get rid of the default value for the price column.