Skip to content

Instantly share code, notes, and snippets.

@rpivo
Last active June 15, 2021 12:34
Show Gist options
  • Save rpivo/649d871922d7f39064cf21b6d374b288 to your computer and use it in GitHub Desktop.
Save rpivo/649d871922d7f39064cf21b6d374b288 to your computer and use it in GitHub Desktop.
Declaring Enum Types in MySQL

Declaring Enum Types in MySQL

The following statement creates a table Products that contains three columns: product_id, low_fats, and recyclable.

While product_id is of type int, both low_fats and recyclable are enums that can only be one of the declared values within the ENUM() clause ('Y' or 'N', in this case).

CREATE TABLE Products (
  product_id int,
  low_fats ENUM('Y', 'N'),
  recyclable ENUM('Y', 'N')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment