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 |
Choose the narrowest type that correctly represents the values you need. For exact money-like values, prefer DECIMAL rather than approximate floating-point types.
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.