Last active
October 25, 2021 23:38
-
-
Save beargiles/186352e588be2510c5ef99cbaf326896 to your computer and use it in GitHub Desktop.
Defining a PostgreSQL enum type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- 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