- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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)
Advertisements