Get startedGet started for free

User-defined data types

ENUM or enumerated data types are great options to use in your database when you have a column where you want to store a fixed list of values that rarely change. Examples of when it would be appropriate to use an ENUM include days of the week and states or provinces in a country.

Another example can be the directions on a compass (i.e., north, south, east and west.) In this exercise, you are going to create a new ENUM data type called compass_position.

This exercise is part of the course

Functions for Manipulating Data in PostgreSQL

View Course

Hands-on interactive exercise

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

-- Create an enumerated data type, compass_position
___ ___ ___ AS ___ (
  	-- Use the four cardinal directions
  	'___', 
  	'___',
  	'___', 
  	'___'
);
Edit and Run Code