{"id":1383,"date":"2010-07-23T12:44:10","date_gmt":"2010-07-23T07:14:10","guid":{"rendered":"https:\/\/tothenewco.pro\/blog\/?p=1383"},"modified":"2015-07-09T15:01:44","modified_gmt":"2015-07-09T09:31:44","slug":"enum-datatype-in-mysql","status":"publish","type":"post","link":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/","title":{"rendered":"Enum datatype in mysql"},"content":{"rendered":"<p>Recently <a title=\"Grails Development Project\" href=\"https:\/\/tothenewco.pro\/success-stories\/sony-entertainment-television\">in a Grails project<\/a> that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be one of value of Enum. So they use to store some different value in it as the datatype of Enums in table is varchar the sql doesn&#8217;t mind storing the different values.<\/p>\n<p>So after looking at here and there for Enum datatypes for sql we found a very easy solution to do that. We altered few tables like this<\/p>\n<pre lang=\"groovy\">alter table documents change document_priority document_priority enum('Critical','Major','Blocker','Backlog') default 'Major';\r\n<\/pre>\n<p>For adding an Enum column you just need to do something like<\/p>\n<pre lang=\"groovy\">alter table documents add column enum('Critical','Major','Blocker','Backlog') \r\n<\/pre>\n<p>after doing this the user can see that which values the field expect so <a title=\"iPhone Developers Team\" href=\"https:\/\/tothenewco.pro\/mobile-ios-application-development-services\">iPhone development team<\/a> also get to know what should they do. But it does not restrict user to other values in it though if user tries to add some other value in it the sql will set it to blank(&#8221; &#8220;). It still doesn&#8217;t serves our purpose because in application there is no blank Enum. The solution for this is in the sql_mode. So we set the sql_mode<\/p>\n<pre lang=\"groovy\">SET sql_mode = STRICT_TRANS_TABLES\r\n<\/pre>\n<p>So can see the sql_mode of your database like this<\/p>\n<pre lang=\"groovy\">SELECT @@global.sql_mode, @@session.sql_mode;\r\n<\/pre>\n<p>I hope this helped for some people the only thing I miss in this. I dont get the solution for this in Hibernate. May be there is a solution for this either in Hibernate or in Grails. Looking for the better solution that can be done in the application itself.<br \/>\nHope it helps<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3,"footnotes":""},"categories":[1],"tags":[340,341,343,342],"class_list":["post-1383","post","type-post","status-publish","format-standard","hentry","category-technology","tag-enum-in-mysql","tag-java-enums-with-sql","tag-sql-modes","tag-strict-values-in-sql"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Uday Pratap Singh\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Enum datatype in mysql | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"article:tag\" content=\"technology\" \/>\n\t\t<meta property=\"article:tag\" content=\"enum in mysql\" \/>\n\t\t<meta property=\"article:tag\" content=\"java enums with sql\" \/>\n\t\t<meta property=\"article:tag\" content=\"sql modes\" \/>\n\t\t<meta property=\"article:tag\" content=\"strict values in sql\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2010-07-23T07:14:10+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2015-07-09T09:31:44+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Enum datatype in mysql | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/#article\",\"name\":\"Enum datatype in mysql | TO THE NEW Blog\",\"headline\":\"Enum datatype in mysql\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/uday\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2010-07-23T12:44:10+05:30\",\"dateModified\":\"2015-07-09T15:01:44+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/#webpage\"},\"articleSection\":\"Technology, Enum in mysql, Java enums with sql, sql modes, strict values in sql\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"position\":2,\"name\":\"Technology\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/#listItem\",\"name\":\"Enum datatype in mysql\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/#listItem\",\"position\":3,\"name\":\"Enum datatype in mysql\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/uday\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/uday\\\/\",\"name\":\"Uday Pratap Singh\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/#authorImage\",\"url\":\"https:\\\/\\\/newersworld-sf-static.tothenew.net\\\/prod\\\/profilePicFolder\\\/d4c98503-ff55-4112-8fc2-e3c4fcc6fc3a_282-Uday-Pratap-Singh-PROFILEPICTURE.jpeg\",\"width\":96,\"height\":96,\"caption\":\"Uday Pratap Singh\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/\",\"name\":\"Enum datatype in mysql | TO THE NEW Blog\",\"description\":\"Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enum-datatype-in-mysql\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/uday\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/uday\\\/#author\"},\"datePublished\":\"2010-07-23T12:44:10+05:30\",\"dateModified\":\"2015-07-09T15:01:44+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Enum datatype in mysql | TO THE NEW Blog","description":"Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be","canonical_url":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/#article","name":"Enum datatype in mysql | TO THE NEW Blog","headline":"Enum datatype in mysql","author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/uday\/#author"},"publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"},"datePublished":"2010-07-23T12:44:10+05:30","dateModified":"2015-07-09T15:01:44+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/#webpage"},"isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/#webpage"},"articleSection":"Technology, Enum in mysql, Java enums with sql, sql modes, strict values in sql"},{"@type":"BreadcrumbList","@id":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/tothenewco.pro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/technology\/#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/technology\/#listItem","position":2,"name":"Technology","item":"https:\/\/tothenewco.pro\/blog\/category\/technology\/","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/#listItem","name":"Enum datatype in mysql"},"previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/#listItem","position":3,"name":"Enum datatype in mysql","previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/technology\/#listItem","name":"Technology"}}]},{"@type":"Organization","@id":"https:\/\/tothenewco.pro\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/tothenewco.pro\/blog\/"},{"@type":"Person","@id":"https:\/\/tothenewco.pro\/blog\/author\/uday\/#author","url":"https:\/\/tothenewco.pro\/blog\/author\/uday\/","name":"Uday Pratap Singh","image":{"@type":"ImageObject","@id":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/#authorImage","url":"https:\/\/newersworld-sf-static.tothenew.net\/prod\/profilePicFolder\/d4c98503-ff55-4112-8fc2-e3c4fcc6fc3a_282-Uday-Pratap-Singh-PROFILEPICTURE.jpeg","width":96,"height":96,"caption":"Uday Pratap Singh"}},{"@type":"WebPage","@id":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/#webpage","url":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/","name":"Enum datatype in mysql | TO THE NEW Blog","description":"Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/#breadcrumblist"},"author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/uday\/#author"},"creator":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/uday\/#author"},"datePublished":"2010-07-23T12:44:10+05:30","dateModified":"2015-07-09T15:01:44+05:30"},{"@type":"WebSite","@id":"https:\/\/tothenewco.pro\/blog\/#website","url":"https:\/\/tothenewco.pro\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"article","og:title":"Enum datatype in mysql | TO THE NEW Blog","og:description":"Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be","og:url":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/","og:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","article:tag":["technology","enum in mysql","java enums with sql","sql modes","strict values in sql"],"article:published_time":"2010-07-23T07:14:10+00:00","article:modified_time":"2015-07-09T09:31:44+00:00","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Enum datatype in mysql | TO THE NEW Blog","twitter:description":"Recently in a Grails project that I am currently working on, the client wanted to have few functionalities of our web application on iPhone as well. We are using Enums heavily in our project and the iPhone development cannot recognize from looking at the tables that few fields are Enums so those need to be","twitter:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"1383","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":"","og_description":"","og_object_type":"article","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":"","og_article_tags":"","twitter_use_og":false,"twitter_card":"summary","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-30 02:10:36","updated":"2024-02-29 09:35:22","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\/category\/technology\/\" title=\"Technology\">Technology<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tEnum datatype in mysql\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/tothenewco.pro\/blog"},{"label":"Technology","link":"https:\/\/tothenewco.pro\/blog\/category\/technology\/"},{"label":"Enum datatype in mysql","link":"https:\/\/tothenewco.pro\/blog\/enum-datatype-in-mysql\/"}],"_links":{"self":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/1383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/comments?post=1383"}],"version-history":[{"count":0,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/1383\/revisions"}],"wp:attachment":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/media?parent=1383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/categories?post=1383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/tags?post=1383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}