

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- How can I use MySQL INTERVAL() function with a column of a table?
- How can I update MySQL table after quoting the values of a column with a single quote?
- How can I create a table with borders in Android?
- 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?
- Can I get the count of repeated values in a column with MySQL?
- How can I get enum possible values in a MySQL database?
- How to create a table with date column?
- How to create a 3-column layout grid with CSS?
- Insertion in a MySQL table with only a single column set as auto_increment?
- How can I drop an existing column from a MySQL table?
- How can I remove every column in a table in MySQL?
Advertisements