How to Do ENUM in PhpMyAdmin

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.

Young smiling woman with ponytail using laptop in cafe
credit: monkeybusinessimages/iStock/Getty Images

Step

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

Step

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

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

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