Every MySQL column has a data type. The type determines what values the column can store, how MySQL interprets them, and how much storage or precision is available.
CREATE TABLE product (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
price DECIMAL(10,2) NOT NULL,
created_at DATETIME NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| Group | Examples | Typical use |
|---|---|---|
| Numeric | INT, BIGINT, DECIMAL, FLOAT, DOUBLE | Counts, IDs, prices, measurements |
| Date & time | DATE, TIME, DATETIME, TIMESTAMP, YEAR | Dates, timestamps, durations |
| Character/text | CHAR, VARCHAR, TEXT | Names, descriptions, text |
| Binary | BINARY, VARBINARY, BLOB | Raw bytes and binary objects |
Boolean values in MySQL: MySQL uses TINYINT(1) for BOOLEAN and BOOL. Learn how TRUE, FALSE, NULL and Boolean comparisons work in our MySQL BOOLEAN and TINYINT(1) tutorial .
Choose the narrowest type that correctly represents the values you need. For exact money-like values, prefer DECIMAL rather than approximate floating-point types.
The sample product table above combines INT for a generated identifier, VARCHAR for names, DECIMAL(10,2) for exact prices and DATETIME for an entered timestamp. The choice of data type changes which values MySQL accepts and how they are handled.
After creating the sample table, insert a row and read it back:
INSERT INTO product (name, price, created_at)
VALUES ('Notebook', 149.50, '2026-11-14 10:30:00');
SELECT name, price, DATE(created_at) AS added_on
FROM product
ORDER BY id;
Result after inserting one row into a new empty product table
| name | price | added_on |
|---|---|---|
| Notebook | 149.50 | 2026-11-14 |
| Need | Typical type | Important detail |
|---|---|---|
| Whole-number counts | INT | Check its signed/unsigned range |
| Money or exact decimals | DECIMAL(M,D) | Set precision and scale to suit the data |
| Names and labels | VARCHAR(n) | Use a suitable character set such as utf8mb4 |
| Long text | TEXT | Different from a binary BLOB |
| Date only | DATE | No time-of-day component |
| Local wall-clock date and time | DATETIME | Not automatically converted by session time zone |
| Raw bytes | BLOB | Use only when the binary content belongs in the database |
DESCRIBE product;
This shows column names, their MySQL types, NULL rules and key/default information. Use SHOW TABLES to see whether the table exists, and CREATE TABLE to define a new one.
Do not assume that integer display width limits the allowed number of digits. Avoid FLOAT for exact financial totals; and remember that VARCHAR, TEXT and BLOB serve different needs. See the dedicated numeric, date/time and binary pages.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.