{"id":412,"date":"2019-10-18T11:24:10","date_gmt":"2019-10-18T04:24:10","guid":{"rendered":"https:\/\/mariadbtutorial.com\/?page_id=412"},"modified":"2020-04-11T23:24:03","modified_gmt":"2020-04-11T16:24:03","slug":"mariadb-data-types","status":"publish","type":"page","link":"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/","title":{"rendered":"MariaDB Data Types"},"content":{"rendered":"\n<p><strong>Summary<\/strong><em>:&nbsp;<\/em>in this tutorial, you will learn about&nbsp;<strong>MariaDB data types <\/strong>and how to use them effectively for designing a table.<\/p>\n\n\n\n<p>Before designing a database in MariaDB, you should consider the available data types so that you can select the most optimal ones for storing data. MariaDB provides you with many data types including:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Numeric data types<\/li><li>String data types<\/li><li>Temporal data types<\/li><li>Spatial data types<\/li><\/ul>\n\n\n\n<p>Each data type has the following properties:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The value that it can present.<\/li><li>The storage size<\/li><li>The values can be indexed or not.<\/li><li>How values can be compared.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">MariaDB numeric data types<\/h2>\n\n\n\n<p>MariaDB supports many kinds of numeric types including the exact and approximate numeric data types.&nbsp;The following table shows the summary of numeric types supported by MariaDB:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Numeric Types<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>&nbsp;<code>TINYINT<\/code><\/td><td>A very small integer<\/td><\/tr><tr><td>&nbsp;<code>SMALLINT<\/code><\/td><td>A small integer<\/td><\/tr><tr><td>&nbsp;<code>MEDIUMINT<\/code><\/td><td>A medium-sized integer<\/td><\/tr><tr><td>&nbsp;<code>INT<\/code><\/td><td>A standard integer<\/td><\/tr><tr><td>&nbsp;<code>BIGINT<\/code><\/td><td>A large integer<\/td><\/tr><tr><td>&nbsp;<code>DECIMAL<\/code><\/td><td>A fixed-point number<\/td><\/tr><tr><td>&nbsp;<code>FLOAT<\/code><\/td><td>A single-precision floating-point number<\/td><\/tr><tr><td>&nbsp;<code>DOUBLE<\/code><\/td><td>A double-precision floating-point number<\/td><\/tr><tr><td>&nbsp;<code>BIT<\/code><\/td><td>A bit<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">MariaDB Boolean data type<\/h3>\n\n\n\n<p>MariaDB uses the <code>TINYINT(1)<\/code> to represent Boolean values. In MariaDB, zero (0) means false and non-zero means true. The <code>BOOLEAN<\/code> and <code>BOOL<\/code> are the synonym of <code>TINYINT(1)<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MariaDB string data types<\/h2>\n\n\n\n<p>MariaDB string types can hold any string data including plain text, binary data, and even contents of files.&nbsp;The following table displays string data types in MariaDB:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>String Types<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>&nbsp;<code>CHAR<\/code><\/td><td>A fixed-length nonbinary (character) string<\/td><\/tr><tr><td>&nbsp;<code>VARCHAR<\/code><\/td><td>A variable-length non-binary string<\/td><\/tr><tr><td>&nbsp;<code>BINARY<\/code><\/td><td>A fixed-length binary string<\/td><\/tr><tr><td>&nbsp;<code>VARBINARY<\/code><\/td><td>A variable-length binary string<\/td><\/tr><tr><td>&nbsp;<code>TINYBLOB<\/code><\/td><td>A very small BLOB (binary large object)<\/td><\/tr><tr><td>&nbsp;<code>BLOB<\/code><\/td><td>A small BLOB<\/td><\/tr><tr><td>&nbsp;<code>MEDIUMBLOB<\/code><\/td><td>A medium-sized BLOB<\/td><\/tr><tr><td>&nbsp;<code>LONGBLOB<\/code><\/td><td>A large BLOB<\/td><\/tr><tr><td>&nbsp;<code>TINYTEXT<\/code><\/td><td>A very small non-binary string<\/td><\/tr><tr><td>&nbsp;<code>TEXT<\/code><\/td><td>A small non-binary string<\/td><\/tr><tr><td>&nbsp;<code>MEDIUMTEXT<\/code><\/td><td>A medium-sized non-binary string<\/td><\/tr><tr><td>&nbsp;<code>LONGTEXT<\/code><\/td><td>A large non-binary string<\/td><\/tr><tr><td>&nbsp;<a href=\"http:\/\/www.mysqltutorial.org\/mysql-enum\/\"><code>ENUM<\/code><\/a><\/td><td>An enumeration<\/td><\/tr><tr><td>&nbsp;<code>SET<\/code><\/td><td>A set<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">MariaDB temporal types<\/h2>\n\n\n\n<p>MySQL temporal types including types that represent a date without time, a time without date, a datetime, a timestamp, and year. This table shows the MariaDB temporal data types:<\/p>\n\n\n\n<figure class=\"wp-block-table ref\"><table><thead><tr><th>Temporal Data Types<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>&nbsp;<code>DATE<\/code><\/td><td>A date value in&nbsp;<code>CCYY-MM-DD<\/code>&nbsp;format<\/td><\/tr><tr><td>&nbsp;<code>TIME<\/code><\/td><td>A time value in&nbsp;<code>hh:mm:ss<\/code>&nbsp;format<\/td><\/tr><tr><td>&nbsp;<code>DATETIME<\/code><\/td><td>A date and time value in<code>CCYY-MM-DD hh:mm:ss<\/code>format<\/td><\/tr><tr><td>&nbsp;<code>TIMESTAMP<\/code><\/td><td>A timestamp value in&nbsp;<code>CCYY-MM-DD hh:mm:ss&nbsp;<\/code>format<\/td><\/tr><tr><td>&nbsp;<code>YEAR<\/code><\/td><td>A year value in&nbsp;<code>CCYY<\/code>&nbsp;or&nbsp;<code>YY&nbsp;<\/code>format<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">MariaDB spatial data types<\/h2>\n\n\n\n<p>MariaDB supports many spatial data types that contain various kinds of geographical values<\/p>\n\n\n\n<figure class=\"wp-block-table ref\"><table><thead><tr><th>Spatial Data Types<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>&nbsp;<code>GEOMETRY<\/code><\/td><td>A spatial value of any type<\/td><\/tr><tr><td>&nbsp;<code>POINT<\/code><\/td><td>A point (a pair of X-Y coordinates)<\/td><\/tr><tr><td>&nbsp;<code>LINESTRING<\/code><\/td><td>A curve (one or more&nbsp;<code>POINT<\/code> values)<\/td><\/tr><tr><td>&nbsp;<code>POLYGON<\/code><\/td><td>A polygon<\/td><\/tr><tr><td>&nbsp;<code>GEOMETRYCOLLECTION<\/code><\/td><td>A collection of&nbsp;<code>GEOMETRY<\/code> values<\/td><\/tr><tr><td>&nbsp;<code>MULTILINESTRING<\/code><\/td><td>A collection of&nbsp;<code>LINESTRING<\/code>values<\/td><\/tr><tr><td>&nbsp;<code>MULTIPOINT<\/code><\/td><td>A collection of&nbsp;<code>POINT<\/code> values<\/td><\/tr><tr><td>&nbsp;<code>MULTIPOLYGON<\/code><\/td><td>A collection of&nbsp;<code>POLYGON<\/code>values<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>In this tutorial, you have learned various MariaDB data types including numeric, string, spatial data types,<\/p>\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=\"412\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/\"\n\t\t\t\tdata-post-title=\"MariaDB Data Types\"\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=\"412\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/\"\n\t\t\t\tdata-post-title=\"MariaDB Data Types\"\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>In this tutorial, you will learn about\u00a0MariaDB data types and how to use them effectively for designing a table.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":95,"menu_order":29,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-412","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MariaDB Data Types<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn about\u00a0MariaDB data types and how to use them effectively for designing a table.\" \/>\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.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MariaDB Data Types\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn about\u00a0MariaDB data types and how to use them effectively for designing a table.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/\" \/>\n<meta property=\"og:site_name\" content=\"MariaDB Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-11T16:24:03+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/\",\"url\":\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/\",\"name\":\"MariaDB Data Types\",\"isPartOf\":{\"@id\":\"https:\/\/www.mariadbtutorial.com\/#website\"},\"datePublished\":\"2019-10-18T04:24:10+00:00\",\"dateModified\":\"2020-04-11T16:24:03+00:00\",\"description\":\"In this tutorial, you will learn about\u00a0MariaDB data types and how to use them effectively for designing a table.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.mariadbtutorial.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MariaDB Basics\",\"item\":\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MariaDB Data Types\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.mariadbtutorial.com\/#website\",\"url\":\"https:\/\/www.mariadbtutorial.com\/\",\"name\":\"MariaDB Tutorial\",\"description\":\"MariaDB Tutorial\",\"publisher\":{\"@id\":\"https:\/\/www.mariadbtutorial.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.mariadbtutorial.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.mariadbtutorial.com\/#organization\",\"name\":\"MariaDB Tutorial\",\"url\":\"https:\/\/www.mariadbtutorial.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.mariadbtutorial.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/mariadbtutorial.com\/wp-content\/uploads\/2019\/06\/favicon.png\",\"contentUrl\":\"https:\/\/mariadbtutorial.com\/wp-content\/uploads\/2019\/06\/favicon.png\",\"width\":512,\"height\":592,\"caption\":\"MariaDB Tutorial\"},\"image\":{\"@id\":\"https:\/\/www.mariadbtutorial.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MariaDB Data Types","description":"In this tutorial, you will learn about\u00a0MariaDB data types and how to use them effectively for designing a table.","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.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/","og_locale":"en_US","og_type":"article","og_title":"MariaDB Data Types","og_description":"In this tutorial, you will learn about\u00a0MariaDB data types and how to use them effectively for designing a table.","og_url":"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/","og_site_name":"MariaDB Tutorial","article_modified_time":"2020-04-11T16:24:03+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/","url":"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/","name":"MariaDB Data Types","isPartOf":{"@id":"https:\/\/www.mariadbtutorial.com\/#website"},"datePublished":"2019-10-18T04:24:10+00:00","dateModified":"2020-04-11T16:24:03+00:00","description":"In this tutorial, you will learn about\u00a0MariaDB data types and how to use them effectively for designing a table.","breadcrumb":{"@id":"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-data-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mariadbtutorial.com\/"},{"@type":"ListItem","position":2,"name":"MariaDB Basics","item":"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/"},{"@type":"ListItem","position":3,"name":"MariaDB Data Types"}]},{"@type":"WebSite","@id":"https:\/\/www.mariadbtutorial.com\/#website","url":"https:\/\/www.mariadbtutorial.com\/","name":"MariaDB Tutorial","description":"MariaDB Tutorial","publisher":{"@id":"https:\/\/www.mariadbtutorial.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mariadbtutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mariadbtutorial.com\/#organization","name":"MariaDB Tutorial","url":"https:\/\/www.mariadbtutorial.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mariadbtutorial.com\/#\/schema\/logo\/image\/","url":"https:\/\/mariadbtutorial.com\/wp-content\/uploads\/2019\/06\/favicon.png","contentUrl":"https:\/\/mariadbtutorial.com\/wp-content\/uploads\/2019\/06\/favicon.png","width":512,"height":592,"caption":"MariaDB Tutorial"},"image":{"@id":"https:\/\/www.mariadbtutorial.com\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.mariadbtutorial.com\/wp-json\/wp\/v2\/pages\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mariadbtutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mariadbtutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mariadbtutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mariadbtutorial.com\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":3,"href":"https:\/\/www.mariadbtutorial.com\/wp-json\/wp\/v2\/pages\/412\/revisions"}],"predecessor-version":[{"id":741,"href":"https:\/\/www.mariadbtutorial.com\/wp-json\/wp\/v2\/pages\/412\/revisions\/741"}],"up":[{"embeddable":true,"href":"https:\/\/www.mariadbtutorial.com\/wp-json\/wp\/v2\/pages\/95"}],"wp:attachment":[{"href":"https:\/\/www.mariadbtutorial.com\/wp-json\/wp\/v2\/media?parent=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}