How to Do ENUM in PhpMyAdmin

By Gary Sims

In MySQL, an enumerated type, or enum for short, is a string with a predefined set of values. Any fields you define using enum can only be assigned a value from that predefined set. For instance, the status of a traffic light can be defined as either red, yellow or green. In MySQL you can represent these colors relatively easily using an enum. Nevertheless, with PhpMyAdmin, the free administration tool for MySQL, you can define and represent enum types even faster.

Step 1

Select the database by clicking on its name from the list on the left-hand side of the phpMyAdmin page.

Step 2

Type "enumtest" in the "Name:" field of the "Create new table on database" section. Type "1" in the "Number of fields:" box. Click the "Go" button.

Step 3

Type "an_enum" in the "Field" edit box. Select "ENUM" from the "Type" drop-down list. Type "'red', 'yellow', 'green'" in the "Length/Values" field. Select "As defined:" from the "Default" drop-down list. Type "red" in the field immediately below it. Click "Save."

Step 4

Click the "Insert" tab. Select either "red", "yellow" or "green" from the "Value" drop-down list. Click the "Go" button.

Tips & Warnings

  • The same result can be achieved in SQL with the following statement: CREATE TABLE enumtest ( an_enum ENUM('red', 'yellow', 'green') default 'red' );