Field Type
MySQL database is designed for professional developers. If you are unfamiliar with database data types, it is recommended to use the Data Model to define the data source structure.
Numeric Type
| Data Type | Value Range | Description | Applicable Scenarios |
|---|---|---|---|
| TINYINT | -128 to 127 (signed) 0 to 255 (unsigned) | Smallest integer type | Status values, age, small numerical values |
| SMALLINT | -32768 to 32767 (signed) 0 to 65535 (unsigned) | Small integer type | Counters; small-range numerical values |
| MEDIUMINT | -8388608 to 8388607 (signed) 0 to 16777215 (unsigned) | Medium integer type | Medium-range counting, IDs |
| INT | -2147483648 to 2147483647 (signed) 0 to 4294967295 (unsigned) | Standard integer type | Primary key IDs, quantities, counts |
| BIGINT | -9223372036854775808 to 9223372036854775807 (signed) | Large integer type | Large numerical values, timestamps, large IDs |
| DECIMAL | Depends on precision and scale settings | Exact decimal type | Monetary amounts, precise calculations |
| FLOAT | Approximately -3.4E+38 to 3.4E+38 | Single-precision floating-point number | Scientific computing, approximate values |
| DOUBLE | Approximately -1.8E+308 to 1.8E+308 | Double-precision floating-point number | High-precision scientific computing |
| REAL | Same as DOUBLE | Synonym for DOUBLE | Used for compatibility |
| BIT | 0 to 2^n-1 | Bit-field type | Flags, bitmasks |
| SERIAL | 1 to 9223372036854775807 | Auto-incrementing large integer (BIGINT UNSIGNED AUTO_INCREMENT) | Auto-increment primary key |
| BOOLEAN | TRUE (1) or FALSE (0) | Boolean type (alias for TINYINT(1)) | Switch states, yes/no decisions |
Date and Time Types
| Data Type | Value Range | Format | Applicable Scenarios |
|---|---|---|---|
| DATE | 1000-01-01 to 9999-12-31 | YYYY-MM-DD | Birthdays, date records |
| DATETIME | 1000-01-01 00:00:00 to 9999-12-31 23:59:59 | YYYY-MM-DD HH:MM:SS | Creation time, update time |
| TIMESTAMP | 1970-01-01 00:00:01 to 2038-01-19 03:14:07 | YYYY-MM-DD HH:MM:SS | Timestamp, automatic update time |
| TIME | -838:59:59 to 838:59:59 | HH:MM:SS | Time periods, duration |
| YEAR | 1901 to 2155 | YYYY | Year records |
Text Type
| Data Type | Maximum Length | Description | Applicable Scenarios |
|---|---|---|---|
| CHAR | 255 characters | Fixed-length string | Fixed-format encoding, status codes |
| VARCHAR | 65535 characters | Variable-length string | Usernames, titles, descriptions |
| TINYTEXT | 255 characters | Short text | Short descriptions, tags |
| TEXT | 65535 characters | Text type | Article content, detailed descriptions |
| MEDIUMTEXT | 16777215 characters | Medium-length text | Long articles, rich text content |
| LONGTEXT | 4294967295 characters | Long text | Large documents, HTML content |
| BINARY | 255 bytes | Fixed-length binary data | Hash values, fixed-length encoding |
| VARBINARY | 65535 bytes | Variable-length binary data | File data, encrypted information |
| TINYBLOB | 255 bytes | Small binary object | Small icons, thumbnails |
| MEDIUMBLOB | 16777215 bytes | Medium binary object | Images, audio files |
| BLOB | 65535 bytes | Binary Large Object | File, image data |
| LONGBLOB | 4294967295 bytes | Long binary object | Large files, video data |
| ENUM | 65535 distinct values | Enumeration type, select one from a predefined list of values | Status values, category options |
| SET | 64 distinct members | Collection type, select multiple from a predefined list of values | Permission settings, multi-select tags |
| JSON | Maximum document size 1GB | JSON format data | Configuration information, structured data |
Spatial Data Types
| Data Type | Description | Applicable Scenarios |
|---|---|---|
| GEOMETRY | General geometry type | Any geometric shape |
| POINT | Point type | Location markers, coordinate points |
| LINESTRING | Line String Type | Paths, trajectories |
| POLYGON | Polygon type | Area boundaries, geofences |
| MULTIPOINT | Multipoint type | Multiple location points |
| MULTILINESTRING | Multi Line String Type | Multiple paths |
| MULTIPOLYGON | MultiPolygon type | Multiple regions |
| GEOMETRYCOLLECTION | Geometry collection type | Collection of mixed geometric objects |