Practice
Data Structures and Algorithms
Machine Coding Round (LLD)
System Design & Architecture (HLD)
Frontend UI Machine Coding
Resources
Career Advice and Roadmaps
Data Structures and Algorithms
Machine Coding Round (LLD)
System Design & Architecture (HLD)
Backend Development
Frontend Development
Project Ideas for Software Developers
Core Computer Science
Companies
SDE Jobs & Internships
Interview Questions
Compare Companies
IDE
Online IDE
Collaborative IDE

Datatypes in MySQL - I | Introduction

Ujjwal Abhishek
Ujjwal Abhishek

Each and every database tables have some columns and rows. Each column contains some value and that value belongs to some data type. The data type of a column describes the data stored in that column.

String data types in MySQL

Some String data types in MySQL are shown in below table:

Data typeDescription
CHAR A fixed-length non-binary string and the length can be anything from 0 to 255.
VARCHARA variable-length non-binary string and the length can be from 0 to 65535
TINYTEXTA very small-sized non-binary string.
TEXTA small-sized non-binary string.
MEDIUMTEXTA medium-sized non-binary string.
LONGTEXTA long-sized non-binary string.
BINARYSimilar to CHAR but it stores binary strings.
VARBINARYSimilar to VARCHAR but it stores binary strings.
TINY BLOBA very small BLOB (Binary Large Objects).
BLOBA small-sized BLOB.
MEDIUMBLOBA medium-sized BLOB.
LONGBLOBA long BLOB.
ENUMA string object with a value chosen from a list of values.
SETA string object and can have 0 or more values chosen from a list of values.

Numeric data types in MySQL

Numeric data types represent numbers like integer, floating-point, fixed-point, etc.

Some Numeric data types in MySQL are shown in below table:

Data typeDescription
BITA bit value.
TINYINTA very small integer value.
SMALLINTA small integer value having unsigned range from 0 to 65535 and signed range from -32768 to 32767.
MEDIUMINTA medium-sized integer. Its unsigned range is from 0 to 16777215 and signed from  -8388608 to 8388607.
INT An integer ranging from 0 to 4294967295 or signed range is from -2147483648 to 2147483647.
BIGINTA big integer value having an unsigned range from 0 to 264-1 or from -263 to 263-1.
DECIMALA fixed-point number.
FLOATA floating-point number.
DOUBLEA double-precision floating point number.

Date and Time Data Types

MySQL has data types for date and time and date and time together. Some of them are shown below:

Data typeDescription
TIMETime in hh:mm:ss format.
DATEA date in YYYY-MM-DD format.
DATETIMEIt is a combination of date and time. Its format is YYYY-MM-DD hh:mm:ss  
TIMESTAMPA timestamp value in the format YYYY-MM-DD hh:mm:ss 
YEARA four-digit year value in the format YYYY.
Ujjwal Abhishek
Ujjwal Abhishek
Ujjwal is final-year CSE Undergraduate, a competitive coder, and a web developer passionate about problem-solving and data structures and algorithms.
SDE Bootcamp - Become a software engineer at a product-based company
Practice Data Structures & Algorithms
Learning Resources
Interview Prep Resources
Blog
  • Career Advice and Roadmaps
  • Data Structures & Algorithms
  • Machine Coding Round (LLD)
  • System Design & Architecture
  • Backend Development
  • Frontend Development
  • Awesome Project Ideas
  • Core Computer Science
Practice Questions
  • Machine Coding (LLD) Questions
  • System Design (HLD) Questions
  • Topic-wise DSA Questions
  • Company-wise DSA Questions
  • DSA Sheets (Curated Lists)
  • JavaScript Interview Questions
  • Frontend UI Machine Coding Questions
Online Compilers (IDE)
  • Online Java Compiler
  • Online C++ Compiler
  • Online C Compiler
  • Online Python Compiler
  • Online JavaScript Compiler
Topic-wise Problems
  • Dynamic Programming Interview Questions
  • Linked List Interview Questions
  • Graph Interview Questions
  • Backtracking Interview Questions
  • Arrays Interview Questions
  • Trees Interview Questions
Company-wise Problems
  • Amazon Interview Questions
  • Microsoft Interview Questions
  • Google Interview Questions
  • Flipkart Interview Questions
  • Adobe Interview Questions
  • Facebook Interview Questions
DSA Sheets (Curated Lists)
  • Top Interview Questions
  • FAANG Interview Questions
  • Most Asked Interview Questions
  • 6 month DSA Practice Sheet
  • 3 month DSA Practice Sheet
  • Last minute DSA Practice Sheet