Do MySQL Can Enum type values contain spaces in it?


Yes, you can include a string value with spaces in ENUM type. Let us first create a table −

mysql> create table DemoTable
   (
   Size ENUM('SMALL SIZE','LARGE SIZE','XL SIZE')
   );
Query OK, 0 rows affected (0.65 sec)

Let us check the description of table using DESC command −

mysql> desc DemoTable;

This will produce the following output −

+-------+-------------------------------------------+------+-----+---------+-------+
| Field | Type                                      | Null | Key | Default | Extra |
+-------+-------------------------------------------+------+-----+---------+-------+
| Size  | enum('SMALL SIZE','LARGE SIZE','XL SIZE') | YES  |     | NULL    |       |
+-------+-------------------------------------------+------+-----+---------+-------+
1 row in set (0.01 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable values('XL SIZE');
Query OK, 1 row affected (0.14 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output. Here, we have displayed an ENUM type value with a space −

+---------+
| Size    |
+---------+
| XL SIZE |
+---------+
1 row in set (0.00 sec)

Updated on: 30-Jul-2019

298 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements