
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can I create a MySQL table with a column with only 3 possible given values?
For this, use the ENUM data type. Let us first create a table −
mysql> create table DemoTable838(Color ENUM('RED','GREEN','BLUE')); Query OK, 0 rows affected (0.67 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable838 values('RED'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable838 values('Green'); Query OK, 1 row affected (0.64 sec) mysql> insert into DemoTable838 values('Blue'); Query OK, 1 row affected (0.88 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable838;
This will produce the following output −
+-------+ | Color | +-------+ | RED | | GREEN | | BLUE | +-------+ 3 rows in set (0.00 sec)
- Related Articles
- How can I update MySQL table after quoting the values of a column with a single quote?
- How can I use MySQL INTERVAL() function with a column of a table?
- How to insert only a single column into a MySQL table with Java?
- How can I create a stored procedure to insert values in a MySQL table?
- How can I create a stored procedure to delete values from a MySQL table?
- How can I create a stored procedure to update values in a MySQL table?
- How can I create a MySQL stored procedure that returns multiple values from a MySQL table?
- How can I create a table with borders in Android?
- Can I get the count of repeated values in a column with MySQL?
- How can we update MySQL table after padding a string with the values of the column?
- How to create a table with date column?
- Insertion in a MySQL table with only a single column set as auto_increment?
- How can I get enum possible values in a MySQL database?
- How can we use MySQL EXPORT_SET() function with column of a table?
- How do I select data from one table only where column values from that table match the column values of another table in MySQL?

Advertisements