ComeçarComece de graça

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.

Este exercício faz parte do curso

Functions for Manipulating Data in PostgreSQL

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

-- Create an enumerated data type, compass_position
___ ___ ___ AS ___ (
  	-- Use the four cardinal directions
  	'___', 
  	'___',
  	'___', 
  	'___'
);
Editar e executar o código