Skip to content

Instantly share code, notes, and snippets.

@beargiles
Last active October 25, 2021 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beargiles/186352e588be2510c5ef99cbaf326896 to your computer and use it in GitHub Desktop.
Save beargiles/186352e588be2510c5ef99cbaf326896 to your computer and use it in GitHub Desktop.
Defining a PostgreSQL enum type
--
-- Create user-defined enum type.
-- (List details with '\dT+ color' in psql)
--
CREATE TYPE color AS ENUM ('RED', 'GREEN', 'BLUE');
--
-- Create a table using the user-defined enum type.
--
CREATE TABLE quark (
color color not null
);
--
-- Insert a value into the table
--
INSERT INTO quark(color) values ('RED'::color);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment