

- 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 get enum possible values in a MySQL database?
We can achieve possible enum value with the help of ‘enum’. The following is the syntax.
yourColumnName ENUM(value1,value2,........................N)
Let us first create a table.
mysql> create table EnumDemo -> ( -> Light int, -> IsONOrOff ENUM('ON','OFF') -> ); Query OK, 0 rows affected (1.06 sec)
In the above table, ENUM is used to get the possible value for “Light”.
Inserting records.
mysql> insert into EnumDemo values(1,'ON'),(0,'OFF'); Query OK, 2 rows affected (0.24 sec) Records: 2 Duplicates: 0 Warnings: 0
To display all the records −
mysql> select *from EnumDemo;
Here is the output. The ENUM values are visible.
+-------+-----------+ | Light | IsONOrOff | +-------+-----------+ | 1 | ON | | 0 | OFF | +-------+-----------+ 2 rows in set (0.07 sec)
- Related Questions & Answers
- How can I get enum possible values in a MySQL database using PHP?
- How can I remove a value from an enum in MySQL?
- How can I get maximum and minimum values in a single MySQL query?
- How can I create a MySQL table with a column with only 3 possible given values?
- How can I insert default value in MySQL ENUM data type?
- How Are MySQL ENUM values sorted?
- Do MySQL Can Enum type values contain spaces in it?
- Can I get the count of repeated values in a column with MySQL?
- How can I count unique records from a column in MySQL database?
- How do I remove a MySQL database?
- How to get the possible values for SET field in MySQL?
- How can I update the boolean values in MySQL?
- How can I set a MySQL database to use MyISAM by default?
- Set ENUM in MySQL for column values
- Can we get total number of rows in a MySQL database?
Advertisements