EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login
Home Data Science Data Science Tutorials MySQL Tutorial MySQL Data Type
Secondary Sidebar
MySQL Tutorial
  • Basic
    • MySQL floor
    • MySQL DESCRIBE table
    • MySQL encryption
    • Introduction to MySQL
    • Is SQL Server a Database?
    • What is MySQL
    • Is MySQL Programming Language
    • MySQL Server
    • MySQL Community Server
    • How To Install MySQL
    • MySQL Versions
    • MySQL OpenSource
    • MySQL GUI Tools
    • MySQL Grant
    • MySQL Error 1064
    • MySQL Drop Database
    • MySQL not equal
    • MySQL SELECT INTO Variable
    • MySQL Commands
    • MySQL Operators
    • What is MySQL Schema
    • Wildcards in MySQL
    • MySQL Constraints
    • MySQL Administration
    • MySQL Data Type
    • MYSQL COMMIT
    • MySQL FORMAT
    • Timestamp to Date in MySQL
    • MySQL DATEDIFF
    • MySQL?Incremental Backup
    • MySQL JSON Data Type
    • MySQL ENUM
    • MySQL Default Port
    • Cheat Sheet MySQL
  • Queries
    • MySQL Queries
    • MySQL Query Commands
    • SELECT in MySQL
    • MySQL INSERT IGNORE
    • MySQL having
    • ORDER BY in MySQL
    • MySQL Cheat Sheet
    • MySQL ORDER BY Random
    • MySQL ORDER BY DESC
    • MySQL GROUP BY
    • MySQL GROUP BY Count
    • MySQL GROUP BY month
    • MySQL WHERE Clause
    • MySQL WITH
    • MySQL FETCH
    • MySQL DDL
    • MySQL DML
    • MySQL WHERE IN Array
    • MySQL Fetch Array
    • MySQL ISNULL
    • MySQL Index Types
    • Mysql? Export Schema
    • Amazon RDS for MySQL
    • MySQL greatest
  • Database
    • What is Data Modeling
    • What is Data Processing
    • DBMS Architecture
    • DBMS Keys
    • Careers in Database Administration
    • What is MySQL Database
    • MySQL Relational Database
    • How to Connect Database to MySQL
    • MySQL Database Repair
    • RDBMS Interview Questions
    • DBMS Interview Questions
  • Functions
    • MySQL Function
    • MySQL Aggregate Function
    • MySQL String functions
    • MySQL Date Functions
    • MySQL Window Functions
    • MySQL Math Functions
    • MySQL Boolean
    • Cursor in MySQL
    • Condition in MySQL
    • MySQL BETWEEN
    • Insert in MySQL
    • MySQL IFNULL()
    • MySQL TIMESTAMPDIFF()
    • MySQL COALESCE()
    • MySQL count()
    • MIN() in MySQL
    • MySQL Numeric
    • MySQL field()
    • MySQL FIND_IN_SET()
    • MySQL avg()
    • MySQL MAX() Function
    • MySQL BIN()
    • MySQL Concat
    • MySQL DECODE()
    • MySQL REGEXP_REPLACE()
    • MySQL Asynchronous
    • MySQL innodb_buffer_pool_size
    • MySQL key_buffer_size
    • MySQL TRUNCATE()
    • MySQL ROW_NUMBER()
    • NOT in MySQL
    • MySQL IN Operator
    • LIKE in MySQL
    • ANY in MySQL
    • MySQL NOT IN
    • MySQL CHECK Constraint
    • MySQL DISTINCT
    • MySQL ALL
    • MySQL Union
    • MySQL UNION ALL
    • MySQL EXISTS
    • MySQL ON DELETE CASCADE
    • MySQL REGEXP
    • MySQL Index
    • MySQL Add Index
    • MySQL REINDEX
    • MySQL UNIQUE INDEX
    • MySQL Clustered Index
    • MySQL? InnoDB Cluster
    • Table in MySQL
    • ALTER TABLE MySQL
    • MySQL Temporary Table
    • MySQL Clone Table
    • MySQL Repair Table
    • MySQL Lock Table
    • MySQL Optimize Table
    • TRUNCATE TABLE MySQL
    • MySQL Table Dump
    • MySQL Update Set
    • MySQL ALTER TABLE Add Column
    • MySQL RANK()
    • MySQL CTE
    • MySQL LAG()
    • MySQL GROUP_CONCAT()
    • MySQL EXTRACT()
    • MySQL REPLACE
    • MySQL AUTO_INCREMENT
    • MySQL SYSDATE()
    • MySQL NULLIF()
    • MySQL Substring
    • MySQL SUBSTRING_INDEX()
    • MySQL LOWERCASE
    • MySQL Row
    • MySQL NOW
    • MySQL CEIL
    • MySQL Alias
    • MySQL Trigger
    • MySQL SHOW Triggers
    • MySQL UPDATE Trigger
    • MySQL DELETE Trigger
    • MySQL AFTER UPDATE Trigger
    • MySQL Stored Procedure
    • ROLLUP in MySQL
    • MySQL? INSTR()
    • MySQL Subquery
    • MySQL Timestamp
    • MySQL? Hour()
    • MySQL MOD()
    • MySQL DATE_FORMAT()
    • ALTER Column in MySQL
    • MySQL Rename Column
    • MySQL Interval
    • MySQL CURDATE
    • MySQL BIT
    • MySQL Binlog
    • MySQL Average
    • MySQL TEXT
    • MySQL SHOW
    • MySQL Offset
    • MySQL Timezone
    • mysql_real_escape_string
    • MySQL Datetime
    • MySQL DATE_SUB()
    • MySQL FULLTEXT
    • MySQL DATE_ADD()
    • MySQL sum()
    • MySQL Merge
    • MySQL BigInt
    • MySQL ROUND
    • MySQL VARCHAR
    • MySQL Decimal
    • MySQL Limit
    • MySQL today()
    • MySQL WEEKDAY
    • MySQL Split
    • MySQL Create Function
    • MySQL BLOB
    • MySQL encode()
    • MySQL Primary Key
    • MySQL Foreign Key
    • Unique Key in MySQL
    • MySQL Drop Foreign Key
    • MySQL DROP TRIGGER
    • MYSQL Database
    • Delete Database MySQL
    • MySQL Root
    • MySQL Root Password
    • MySQL Client
    • MySQL Users
    • MySQL?User Permissions
    • MySQL add user
    • MySQL List User
    • MySQL Show Users
    • MySQL User Password
    • MySQL?Cardinality
    • MySQL Workbench
    • MySQL Backup
    • MySQL REVOKE
    • MySQL Dump
    • MySQL Cluster
    • MySQL Partitioning
    • MySQL Full Text Search
    • MySQL Admin Tool
    • MySQL Export Database
    • MySQL Export to CSV
  • Joins
    • Joins in MySQL
    • MySQL Outer Join
    • Left Outer Join in MySQL
    • MySQL Self Join
    • Natural Join in MySQL
    • MySQL DELETE JOIN
    • MySQL Update Join
    • MySQL Cross Join
  • Advanced
    • MySQL Formatter
    • MySQL TINYINT
    • MySQL Grant All Privileges
    • MySQL DROP TABLE
    • MySQL rename database
    • MySQL Flush Privileges
    • MySQL super Privilege
    • MySQL Character Set
    • MySQL Log File
    • MySQL Flush Log
    • Grant Privileges MySQL
    • MySQL WHILE LOOP
    • IF Statement in MySQL
    • MySQL CASE Statement
    • MySQL IF Function
    • MySQL IF EXISTS
    • MySQL UUID
    • Views in MySQL
    • MySQL Replication
    • MySQL Partition
    • Toad for MySQL
    • Navicat for MySQL
    • MySQL AES_Encrypt
    • MySQL Performance Tuning
    • MySQL Transaction
    • MySQL? sort_buffer_size
    • MySQL? Sync
    • MySQL? Query Cache
    • MySQL Collation
    • MySQL ODBC Driver
    • MySQL Partitioning
    • MySQL InnoDB
    • MySQL Float vs Decimal
    • MySQL Union vs Union All
  • Interview Questions
    • MySQL Interview Questions

Related Courses

MS SQL Certification Courses

Oracle Certification Courses

PL/SQL Certification Courses

MySQL Data Type

By Payal UdhaniPayal Udhani

MySQL Data Type

Introduction to MySQL Data Type

When dealing with any relational database, you need to use the tables to store the data. These tables can contain multiple columns to store the number of the fields for each record. A single row corresponds to a single record of that table. When you define the fields to be stored in the table while creating it, you need to specify the name of the column and the corresponding data type and other constraints and properties if any. Data types play a crucial role while designing the tables and their columns. You need to consider the purpose of the column, what type of values will be stored in it, the range of the values that will be stored, and the format in which the data needs to be stored for each column. All these things are defined by the data type that you are using for each column of the table. In this article, we will learn about the data types available in MySQL, their range, and other details and also discuss their usage and purpose.

Characteristics of datatypes in MySQL

MySQL provides many datatypes other than numeric and string types to store the values in the columns. These datatypes can be used to specify the behavior of the columns and type of values that will be allowed to store in it. Datatypes in MySQL are associated with multiple characteristics that are as defined below:

The type of values that will be stored and represented in the declared columns.

The memory space requirement of that datatype for storage and also to define whether the values in that column will be of variable or fixed length.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Whether the column’s values for that datatype can be used for indexing.

All in One Data Science Bundle(360+ Courses, 50+ projects)
Python TutorialMachine LearningAWSArtificial Intelligence
TableauR ProgrammingPowerBIDeep Learning
Price
View Courses
360+ Online Courses | 50+ projects | 1500+ Hours | Verifiable Certificates | Lifetime Access
4.7 (86,171 ratings)

Comparison of that values of that datatype with other values in MySQL.

MySQL Data Type

Mysql provides various data types that are further grouped based on the kind of the values stored in that datatype columns. The datatypes can be broadly classified into the following groups:

Datatypes in MySQL

We will discuss and have a look at the datatypes under each group in the list manner that will contain the name of all data types. Before that let us have a brief overlook of some of the most used data types out them along with the range of the values and kind of content that will be stored in them.

Name of datatype

Range

Kind of data stored

VARCHAR (0 – 255) String
CHAR (0 – 255) String
INT (-2147483648 to 214748- 3647) Integer
TINYINT (-128 to 127) Integer
MEDIUMINT (-8388608 to 8388607) Integer
BIGINT (-9223372036854775808 to 9223372036854775807) Integer
SMALLINT (-32768 to 32767) Integer
TEXT 0 – 65535 String
DOUBLE (24 to 53 digits) Decimal
BLOB (0 – 65535) String
DECIMAL (24 to 53 digits) Double value but stored in string format
BOOLEAN 1 TINYINT
DATETIME YYYY-MM-DD HH:MM: SS
TIME HH:MM: SS
DATE YYYY-MM-DD
ENUM Can store one of the defined options of values
SET Can store selected values of the defined options of values

1. String Data Types

We can store the binary data like images of other media files and even plain test in the string data type values in MySQL. Further, MySQL provides different functionalities for searching the string values using regular expressions, like operator or full-text search that help in using and manipulating string values.

The following list contains all the available data types that help to store string values:

  • TEXT
  • LONGTEXT
  • MEDIUMTEXT
  • TINYTEXT
  • BLOB
  • MEDIUMBLOB
  • TINYBLOB
  • LONGBLOB
  • CHAR
  • VARCHAR
  • ENUM
  • SET
  • BINARY
  • VARBINARY

2. Numeric Data type

We can store numeric values of different ranges and formats in MySQL. Exact and approximate numeric values can be stored using MySQL numeric datatypes. Besides that, MySQL also provides the functionality to store the bit values using the BIT data type.

The following list contains all the numeric data types available in MySQL.

  • INT
  • SMALLINT
  • BIGINT
  • MEDIUMINT
  • TINYINT
  • FLOAT
  • DECIMAL
  • DOUBLE
  • BIT

3. Boolean Data Type

Mysql does not provide a dedicated data type for storing boolean values. However, whenever a BOOLEAN or BOOL named datatype is created in MySQL it is internally interpreted as TINYINT(1) datatype by MySQL.

4. Date and Time Data Types

We can store date, time individually as well as togetherly in MySQL. The timestamp can also be used to store and track the changes to the rows of the table. Besides that, if you want to store just a year then you can use the YEAR data type.

The following list contains all the date and time-related data types available in MySQL.

  • DATETIME
  • DATE
  • TIME
  • YEAR
  • TIMESTAMP

5. Spatial Data Type

MySQL provides us the facility to store the geometrical and geographical values in various data types.

The following list contains all the spatial data types available in MySQL.

  • GEOMETRY
  • MULTIPOINT
  • POINT
  • MULTIPOLYGON
  • LINESTRING
  • GEOMETRY COLLECTION
  • MULTILINESTRING
  • POLYGON

6. JSON Data Type

Mysql version 5.7.8 and further comes with the support of storing the JSON data type for storing and manipulating documents of JSON easily and efficiently. Validation of the JSON documents is done automatically when the column is declared to be of JSON data type in MySQL. This datatype provides optimal storage of JJSON documents that can be handled and stored effectively.

Conclusion

MySQL comes with multiple data types that can be used to declare the type of the value, its format, nature, storage space required, and comparison basis. Different data types are grouped in MySQL depending on the kind of values stored in those columns. Which data type should be used to store the values in your columns of the table depends on all the above factors. You should consider the type of value and the range up to which the value can extend while determining the datatype to be assigned to the column.

Recommended Articles

This is a guide to MySQL Data Type. Here we discuss an introduction to MySQL Data Type, characteristics, and 6 different types in detail. You can also go through our other related articles to learn more –

  1. MySQL BIN()
  2. Metadata in SQL
  3. MySQL INSTR()
  4. MySQL WHILE LOOP
Popular Course in this category
MySQL Training Program (12 Courses, 10 Projects)
  12 Online Courses |  10 Hands-on Projects |  92+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

MS SQL Training (16 Courses, 11+ Projects)4.9
Oracle Training (14 Courses, 8+ Projects)4.8
PL SQL Training (4 Courses, 2+ Projects)4.7
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

SPSS, Data visualization with Python, Matplotlib Library, Seaborn Package

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more