MYSQL Tutorial



MYSQL DATA TYPES


MySQL Data Types

Data types define the kind of data a column can hold in a MySQL table. Choosing the right data type helps in efficient storage and better performance.

🔹 Common MySQL Data Types

Data Type Description Example
INT Integer number (whole numbers without decimals) 42, 100, -5
VARCHAR(size) Variable-length string (text) up to specified size 'John Doe', 'hello123'
TEXT Large text data 'This is a long description...'
DATE Date value (YYYY-MM-DD) '2025-05-16'
FLOAT Floating point number (decimals) 3.14, 0.01
BOOLEAN True or False value TRUE, FALSE

🔹 Example Usage in CREATE TABLE

CREATE TABLE products (
  product_id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(255) NOT NULL,
  description TEXT,
  price FLOAT,
  in_stock BOOLEAN,
  created_at DATE
);
  

This table stores product details using different data types like integers, strings, text, decimals, boolean, and dates.

Tip: Always pick the smallest data type that fits your needs — it helps your database perform better and saves storage space!

🌟 Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review