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.
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 |
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.
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!