Data Types
Table 2.5.2: Common MySQL data types: INTEGER
| Data type | Storage | Notes |
|---|---|---|
| TINYINT | 1 byte | Signed range: -128 to 127 Unsigned range: 0 to 255 |
| SMALLINT | 2 bytes | Signed range: -32,768 to 32,767 Unsigned range: 0 to 65,535 |
| MEDIUMINT | 3 bytes | Signed range: -8,388,608 to 8,388,607 Unsigned range: 0 to 16,777,215 |
| INTEGER or INT | 4 bytes | Signed range: -2,147,483,648 to 2,147,483,647 Unsigned range: 0 to 4,294,967,295 |
| BIGINT | 8 bytes | Signed range: -263 to 263 -1 Unsigned range: 0 to 264 -1 263 is 9,223,372,036,854,775,808. 264 is 18,446,744,073,709,551,616. |
Table 2.5.2: Common MySQL data types: DECIMAL
| Data type | Storage | Notes |
|---|---|---|
| DECIMAL(M,D) | Varies depending on M and D | Exact decimal number where M = number of significant digits, D = number of digits after decimal point |
| FLOAT | 4 bytes | Approximate decimal numbers with range: -3.4E+38 to 3.4E+38 |
| DOUBLE | 8 bytes | Approximate decimal numbers with range: -1.8E+308 to 1.8E+308 |
Table 2.5.2: Common MySQL data types: DATE and TIME
| Data type | Storage | Notes |
|---|---|---|
| DATE | 3 bytes | Format: YYYY-MM-DD. Range: ‘1000-01-01’ to ‘9999-12-31’ |
| TIME | 3 bytes | Format: hh:mm:ss |
| DATETIME | 5 bytes | Format: YYYY-MM-DD hh:mm:ss. Range: ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’. |
Table 2.5.2: Common MySQL data types: CHARACTER
| Data type | Storage | Notes |
|---|---|---|
| CHAR(N) | N bytes | Fixed-length string of length N; 0 ≤ N ≤ 255 |
| VARCHAR(N) | Number of characters + 1 byte if N ≤ 255 + 2 bytes if N > 255 |
Variable-length string with maximum N characters; 0 ≤ N ≤ 65,535 |
| TEXT | Number of characters + 2 bytes |
Variable-length string with maximum 65,535 characters |