{"id":6003,"date":"2017-07-05T02:18:23","date_gmt":"2017-07-05T09:18:23","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=6003"},"modified":"2024-01-29T20:43:01","modified_gmt":"2024-01-30T03:43:01","slug":"mysql-enum","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/","title":{"rendered":"MySQL ENUM"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use MySQL <code>ENUM<\/code> data type for defining columns that store enumeration values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL ENUM data type<\/h2>\n\n\n\n<p>In MySQL, an <code>ENUM<\/code> is a string object whose value is chosen from a list of permitted values defined at the time of column creation.<\/p>\n\n\n\n<p>To define an <code>ENUM<\/code> column, you use the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">column_name ENUM('value1', 'value2', ..., 'valueN')<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>column_name<\/code>: This is the name of the column that uses the <code>ENUM<\/code> data type <\/li>\n\n\n\n<li><code>'value1'<\/code>, <code>'value2'<\/code>, &#8230; <code>'valueN'<\/code>: These are the list of values that the column can hold. The values are separated by commas.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">MySQL ENUM data type example<\/h2>\n\n\n\n<p>Suppose you have to store ticket information with the priority: low, medium, and high. To assign these string values to the <code>priority<\/code> column, you can use the <code>ENUM<\/code> data type. <\/p>\n\n\n\n<p>First, <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-create-table\/\">create a new table<\/a> that includes a <code>priority<\/code> column with the <code>ENUM<\/code> type:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> tickets (\n    <span class=\"hljs-keyword\">id<\/span> <span class=\"hljs-built_in\">INT<\/span> PRIMARY <span class=\"hljs-keyword\">KEY<\/span> AUTO_INCREMENT,\n    title <span class=\"hljs-built_in\">VARCHAR<\/span>(<span class=\"hljs-number\">255<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n    <span class=\"hljs-keyword\">priority<\/span> ENUM(<span class=\"hljs-string\">'Low'<\/span>, <span class=\"hljs-string\">'Medium'<\/span>, <span class=\"hljs-string\">'High'<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>\n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>priority<\/code> column accepts only three values <code>Low<\/code>, <code>Medium<\/code> and <code>High<\/code>. <\/p>\n\n\n\n<p>Behind the scenes, MySQL maps each enumeration member to a numeric index. In this case, it maps the Low, Medium, and High values to 1, 2, and 3 respectively.<\/p>\n\n\n\n<p>Second, <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-insert\/\">insert a new row<\/a> into the <code>tickets<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> tickets(title, <span class=\"hljs-keyword\">priority<\/span>)\n<span class=\"hljs-keyword\">VALUES<\/span>(<span class=\"hljs-string\">'Scan virus for computer A'<\/span>, <span class=\"hljs-string\">'High'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, we use the predefined value <code>'High'<\/code> to insert into the <code>priority<\/code> column.<\/p>\n\n\n\n<p>Besides the enumeration values, you can use the numeric index of the enumeration member to insert data into an <code>ENUM<\/code> column. <\/p>\n\n\n\n<p>Third, insert a new row into the <code>tickets<\/code> table using a numeric index value instead of the predefined values:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> tickets(title, <span class=\"hljs-keyword\">priority<\/span>)\n<span class=\"hljs-keyword\">VALUES<\/span>(<span class=\"hljs-string\">'Upgrade Windows OS for all computers'<\/span>, <span class=\"hljs-number\">1<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, instead of using the <code>Low<\/code> enumeration value, we used value 1. Since <code>Low<\/code> is mapped to 1, it is acceptable.<\/p>\n\n\n\n<p>Fourth, <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-insert-multiple-rows\/\">insert multiple rows<\/a> into the <code>tickets<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> tickets(title, <span class=\"hljs-keyword\">priority<\/span>)\n<span class=\"hljs-keyword\">VALUES<\/span>(<span class=\"hljs-string\">'Install Google Chrome for Mr. John'<\/span>, <span class=\"hljs-string\">'Medium'<\/span>),\n      (<span class=\"hljs-string\">'Create a new user for the new employee David'<\/span>, <span class=\"hljs-string\">'High'<\/span>);     <\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Because we define the <code>priority<\/code> as a <code>NOT NULL<\/code> column, when you insert a new row without specifying the value for the <code>priority<\/code> column, MySQL will use the first enumeration member as the default value. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> tickets(title)\n<span class=\"hljs-keyword\">VALUES<\/span>(<span class=\"hljs-string\">'Refresh the computer of Ms. Lily'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The contents of the <code>tickets<\/code> table are as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">+----+----------------------------------------------+----------+\n| id | title                                        | priority |\n+----+----------------------------------------------+----------+\n|  <span class=\"hljs-number\">1<\/span> | Scan virus <span class=\"hljs-keyword\">for<\/span> computer A                    | High     |\n|  <span class=\"hljs-number\">2<\/span> | Upgrade Windows OS <span class=\"hljs-keyword\">for<\/span> all computers         | Low      |\n|  <span class=\"hljs-number\">3<\/span> | Install Google Chrome <span class=\"hljs-keyword\">for<\/span> Mr. John           | Medium   |\n|  <span class=\"hljs-number\">4<\/span> | Create a <span class=\"hljs-keyword\">new<\/span> user <span class=\"hljs-keyword\">for<\/span> the <span class=\"hljs-keyword\">new<\/span> employee David | High     |\n|  <span class=\"hljs-number\">5<\/span> | Refresh the computer <span class=\"hljs-keyword\">of<\/span> Ms. Lily             | Low      |\n+----+----------------------------------------------+----------+\n<span class=\"hljs-number\">5<\/span> rows <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">set<\/span> (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In the non-strict SQL mode, if you insert an invalid value into an <code>ENUM<\/code> column, MySQL will use an empty string <code>''<\/code> with the numeric index <code>0<\/code> for inserting. <\/p>\n\n\n\n<p>If you enable the SQL strict mode and you attempt to insert an invalid <code>ENUM<\/code> value, you will get an error. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">INSERT INTO tickets(title, priority)\nVALUES(<span class=\"hljs-string\">'Invalid ticket'<\/span>,<span class=\"hljs-number\">-1<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Error:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">ERROR <span class=\"hljs-number\">1265<\/span> (<span class=\"hljs-number\">01000<\/span>): Data truncated <span class=\"hljs-keyword\">for<\/span> column <span class=\"hljs-string\">'priority'<\/span> at row <span class=\"hljs-number\">1<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"note\">Note that an <code>ENUM<\/code> column can accept <code>NULL<\/code> values if you define it as a&nbsp;nullable column.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Filtering MySQL ENUM values<\/h2>\n\n\n\n<p>The following statement retrieves all the tickets with high priority:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n  * \n<span class=\"hljs-keyword\">FROM<\/span> \n  tickets \n<span class=\"hljs-keyword\">WHERE<\/span> \n  <span class=\"hljs-keyword\">priority<\/span> = <span class=\"hljs-string\">'High'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">+----+----------------------------------------------+----------+\n| id | title                                        | priority |\n+----+----------------------------------------------+----------+\n|  <span class=\"hljs-number\">1<\/span> | Scan virus <span class=\"hljs-keyword\">for<\/span> computer A                    | High     |\n|  <span class=\"hljs-number\">4<\/span> | Create a <span class=\"hljs-keyword\">new<\/span> user <span class=\"hljs-keyword\">for<\/span> the <span class=\"hljs-keyword\">new<\/span> employee David | High     |\n+----+----------------------------------------------+----------+<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Because the enumeration member <code>'High'<\/code> is mapped to 3, the following query returns the same result set:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n  * \n<span class=\"hljs-keyword\">FROM<\/span> \n  tickets \n<span class=\"hljs-keyword\">WHERE<\/span> \n  <span class=\"hljs-keyword\">priority<\/span> = <span class=\"hljs-number\">3<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Sorting MySQL ENUM values<\/h2>\n\n\n\n<p>MySQL <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-order-by\/\">sorts<\/a> <code>ENUM<\/code> values based on their index numbers. Therefore, the order of members depends on how they were defined in the enumeration list.<\/p>\n\n\n\n<p>The following query selects the tickets and sorts them by priority from <code>High<\/code> to <code>Low<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n  title, \n  <span class=\"hljs-keyword\">priority<\/span> \n<span class=\"hljs-keyword\">FROM<\/span> \n  tickets \n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> \n  <span class=\"hljs-keyword\">priority<\/span> <span class=\"hljs-keyword\">DESC<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">+----------------------------------------------+----------+\n| title                                        | priority |\n+----------------------------------------------+----------+\n| Scan virus <span class=\"hljs-keyword\">for<\/span> computer A                    | High     |\n| Create a <span class=\"hljs-keyword\">new<\/span> user <span class=\"hljs-keyword\">for<\/span> the <span class=\"hljs-keyword\">new<\/span> employee David | High     |\n| Install Google Chrome <span class=\"hljs-keyword\">for<\/span> Mr. John           | Medium   |\n| Upgrade Windows OS <span class=\"hljs-keyword\">for<\/span> all computers         | Low      |\n| Refresh the computer <span class=\"hljs-keyword\">of<\/span> Ms. Lily             | Low      |\n+----------------------------------------------+----------+\n<span class=\"hljs-number\">5<\/span> rows <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">set<\/span> (0.01 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It&#8217;s a good practice to define the enumeration values in the order that you want to sort when you create the <code>ENUM<\/code> column.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Advantages of ENUM data type<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Data Validation:<\/strong> <code>ENUM<\/code> data types provide strong data validation because they restrict column values to a predefined set of options. This helps maintain data integrity.<\/li>\n\n\n\n<li><strong>Readability:<\/strong> <code>ENUM<\/code> values are human-readable and self-explanatory, making it easy to understand the data in the column.<\/li>\n\n\n\n<li><strong>Space Efficiency:<\/strong> <code>ENUM<\/code> values are stored as integers, which are more space-efficient than storing strings.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Limitations of ENUM data type<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Limited Flexibility:<\/strong> Once <code>ENUM<\/code> values are defined, they cannot be easily changed or extended. If you need to add or remove values, you may need to alter the table structure, which can be a complex operation.<\/li>\n\n\n\n<li><strong>Portability:<\/strong> The <code>ENUM<\/code> data type is specific to MySQL and may not be supported in other database systems.<\/li>\n\n\n\n<li><strong>Maintenance:<\/strong> <code>ENUM<\/code> values can make the schema harder to maintain as the application evolves, as adding or removing values can be complex.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use MySQL <code>ENUM<\/code> for defining columns with a limited set of allowed values.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"6003\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/\"\n\t\t\t\tdata-post-title=\"MySQL ENUM\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"6003\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/\"\n\t\t\t\tdata-post-title=\"MySQL ENUM\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary: in this tutorial, you will learn how to use MySQL ENUM data type for defining columns that store enumeration values. Introduction to MySQL ENUM data type In MySQL, an ENUM is a string object whose value is chosen from a list of permitted values defined at the time of column creation. To define an [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":174,"menu_order":81,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-6003","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL ENUM Data Type<\/title>\n<meta name=\"description\" content=\"This tutorial introduces you to MySQL ENUM data type and shows you how to define ENUM columns for storing enumeration values.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL ENUM Data Type\" \/>\n<meta property=\"og:description\" content=\"This tutorial introduces you to MySQL ENUM data type and shows you how to define ENUM columns for storing enumeration values.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-30T03:43:01+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-enum\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-enum\\\/\",\"name\":\"MySQL ENUM Data Type\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"datePublished\":\"2017-07-05T09:18:23+00:00\",\"dateModified\":\"2024-01-30T03:43:01+00:00\",\"description\":\"This tutorial introduces you to MySQL ENUM data type and shows you how to define ENUM columns for storing enumeration values.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-enum\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-enum\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-enum\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Basics\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL ENUM\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL ENUM Data Type","description":"This tutorial introduces you to MySQL ENUM data type and shows you how to define ENUM columns for storing enumeration values.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/","og_locale":"en_US","og_type":"article","og_title":"MySQL ENUM Data Type","og_description":"This tutorial introduces you to MySQL ENUM data type and shows you how to define ENUM columns for storing enumeration values.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-30T03:43:01+00:00","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/","url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/","name":"MySQL ENUM Data Type","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"datePublished":"2017-07-05T09:18:23+00:00","dateModified":"2024-01-30T03:43:01+00:00","description":"This tutorial introduces you to MySQL ENUM data type and shows you how to define ENUM columns for storing enumeration values.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-enum\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Basics","item":"https:\/\/www.mysqltutorial.org\/mysql-basics\/"},{"@type":"ListItem","position":3,"name":"MySQL ENUM"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=6003"}],"version-history":[{"count":3,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6003\/revisions"}],"predecessor-version":[{"id":14608,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6003\/revisions\/14608"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/174"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=6003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}