Data.type | Description |
---|---|
BOOL |
Zero is False, otherwise True |
TINYINT(size) |
A very small integer; from -128 to 127 SIGNED, 0 to 255 UNSIGNED. |
SMALLINT(size) |
Small integer; from -32768 to 32767 SIGNED, 0 to 65535 UNSIGNED. |
MEDIUMINT(size) |
Medium integer; from -8388608 to 8388607 SIGNED, 0 to 16777215 UNSIGNED. |
INT(size) |
Medium integer; from -2147483648 to 2147483647 SIGNED, 0 to 4294967295 UNSIGNED. |
BIGINT(size) |
Big integer; from -9223372036854775808 to 9223372036854775807 SIGNED; 0 to 18446744073709551615 UNSIGNED. |
FLOAT(size,d) |
Small floating point number with a floating decimal point (d). |
DOUBLE(size,d) |
Large number with a floating point number (d). |
DECIMAL(size,d) |
An exact fixed decimal point (d). The maximum value of size is 65 and d is 30. |
DOUBLE PRECISION(size, d) |
Double precision format |
4 SQL Data Types
4.1 Number
4.2 Character
Data.type | Description |
---|---|
CHAR(size) |
Fixed length string with letters, numbers and special characters. Size range: 0 to 255. |
VARCHAR(size) |
A variable length string with letters, numbers and special characters. Size range: 0 to 65535. |
TINYTEXT |
A string with a maximum length of 255 characters. |
TEXT |
A string with a maximum length of 65,535 characters. |
BLOB |
A Binary Large Object that can store up to 65,535 bytes of data. |
MEDIUMTEXT |
A string with a maximum length of 16,777,215 characters |
MEDIUMBLOB |
A medium BLOB that can store up to 16,777,215 bytes of data |
LONGTEXT |
A string with a maximum length of 4,294,967,295 characters |
LONGBLOB |
A large BLOB that can store up to 4,294,967,295 bytes of data |
The size
in numeric and character variables specifies the display width for zero fill. Many SQL databases do not use this notation for specifying the number of digits directly.
For numeric variable, size
is the total number of digits, and d
is the number of digits after the decimal point.
4.3 Datetimes
Data.type | Description |
---|---|
DATE |
A Date. Format: YYYY-MM-DD. The supported range is from 1000-01-01 to 9999-12-31 |
DATETIME |
A date and time combination. Format: YYYY-MM-DD HH:MI:SS. The supported range is from 1000-01-01 00:00:00 to 9999-12-31 23:59:59 |
TIMESTAMP |
A timestamp. TIMESTAMP values are stored as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). Format: YYYY-MM-DD HH:MI:SS. The supported range is from 1970-01-01 00:00:01 UTC to 2038-01-09 03:14:07 UTC |
TIME |
A time. Format: HH:MI:SS. The supported range is from -838:59:59 to 838:59:59 |
YEAR |
A year in two-digit or four-digit format. Values allowed in four-digit format: 1901 to 2155. Values allowed in two-digit format: 70 to 69, representing years from 1970 to 2069 |
5 Example
Data.type | Example |
---|---|
CHAR (20) |
This is a text |
VARCHAR (20) |
This is a text |
TINYINT(3) |
123 |
SMALLINT ,INT
|
1234 |
FLOAT , DOUBLE
|
1234.567 |
DOUBLE PRECISION |
1.23E-04 |
DATE |
2024-09-04 |
TIME (2) |
12:45:05.43 |
TIMESTAMP (0) |
2024-09-04 12:45:05 |
In the expression TIME(2)
, (2)
refers to fractional seconds precision, not the general use of TIME.
In the expression TIMESTAMP(0)
, (0)
refers to the precision of fractional seconds.