Get startedGet started for free

The public schema

The public schema of a PostgreSQL database is created by default when a new database is created. All users by default have access to this schema unless this access is explicitly restricted. When a database is going to be used by a single user and does not have complex groupings of data objects beyond what can naturally be supported by an object-relational database, the public schema will usually suffice. No additional schemas need to be added to such a database. This exercise will help to reinforce the idea that the public schema can be ignored in most basic usage of PostgreSQL.

This exercise is part of the course

Creating PostgreSQL Databases

View Course

Exercise instructions

  • Imagine that you are currently using the pod database described in previous lessons. Create a table named users (to represent listeners of podcasts on the platform) to the pod database such that it is added to the public schema.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- Add users table to the public schema for the pod database
___ ___ ___ (
  id serial PRIMARY KEY,
  first_name TEXT NOT NULL,
  last_name TEXT NOT NULL,
  email TEXT NOT NULL,
  hashed_password CHAR(72) NOT NULL
);
Edit and Run Code