MySQL Data Types (original) (raw)

Last Updated : 19 Mar, 2026

MySQL Data Types define the type of data that can be stored in a table column. They help ensure that data is stored in a structured and efficient way.

MySQL data types are mainly divided into the following categories:

1. Numeric Data Types

Numeric Data Types in MySQL are used to store numeric values such as integers and decimal numbers. They allow databases to perform mathematical operations and store numbers with different ranges and precision.

**Example: Creates a Products table where INT stores whole numbers and DECIMAL(10,2) stores precise price values.

CREATE TABLE Products (
product_id INT,
price DECIMAL(10,2),
quantity INT
);

2. String Data Types

String Data Types in MySQL are used to store text or character data. These data types allow storing names, descriptions, emails, and other textual information.

**Example: Creates a Users table where VARCHAR stores variable-length text and TEXT stores longer descriptions.

CREATE TABLE Users (
name VARCHAR(50),
email VARCHAR(100),
description TEXT
);

3. Date and Time Data Types

Date and Time Data Types in MySQL are used to store date and time values. They help manage information such as timestamps, event dates, and schedules.

**Example: Creates an Orders table where DATE stores the order date and TIME stores the order time.

CREATE TABLE Orders (
order_id INT,
order_date DATE,
order_time TIME
);

4. Spatial Data Types

Spatial Data Types in MySQL are used to store geometric and geographic data. These data types are commonly used in location-based applications and geographic information systems.

**Example: Creates a Locations table where POINT stores geographic coordinates.

CREATE TABLE Locations (
location_id INT,
coordinates POINT
);

Choosing the Right Data Type

Selecting the correct data type is important for efficient storage and performance. Some key considerations include: