Home : Bits and Bytes : Enum Definition


Enum, short for "enumerated," is a data type that consists of predefined values. A constant or variable defined as an enum can store one of the values listed in the enum declaration.

Enums are used in both source code and database tables. For example, an enum that stores multiple colors may be declared in C# as follows:

enum Color { white, red, green, blue, black };

A column in a MySQL database table may be defined as below:

Color ENUM ('white', 'red', 'green', 'blue', 'black')

A variable or database value defined as Color can be assigned any of the five colors listed in the enum declarations above. If assigned any other value besides the one of the five colors above, it will remain undefined and may produce an error depending on the context. Also, enum variables may only contain one value. If a variable may need to store one or more predefined values, it should be defined as a SET instead.

Enums provide a highly structured way to store data since they can only store a single pre-defined value. While this helps ensure data integrity, it also limits their flexibility. Therefore, enum variables are most appropriate for storing discrete data that can only be one of a few possible values. Examples include colors, sizes, categories, months, and days of the week. Variables that contain more varied data, such as names and places, should be defined as strings.

Updated: November 25, 2015

Cite this definition:


TechTerms - The Tech Terms Computer Dictionary

This page contains a technical definition of Enum. It explains in computing terminology what Enum means and is one of many computing terms in the TechTerms dictionary.

All definitions on the TechTerms website are written to be technically accurate but also easy to understand. If you find this Enum definition to be helpful, you can reference it using the citation links above. If you think a term should be updated or added to the TechTerms dictionary, please email TechTerms!

Subscribe to the TechTerms Newsletter to get featured terms and quizzes right in your inbox. You can choose to receive either a daily or weekly email.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe at any time.
Questions? Please contact us.