What are the datatypes used in MYSQL?
Some of the datatypes used in SQL are listed below:
Numeric Data Types:
TINYINT:
- Size: 1 byte
- Range: -128 to 127
SMALLINT:
- Size: 2 bytes
- Range: -32,768 to 32,767
INTEGER or INT:
- Size: 4 bytes
- Range: -2,147,483,648 to 2,147,483,647
MEDIUM INT:
- Size: 8 bytes
- Range: -8388608 to 8388607
BIG INT:
Size: 8 bytes
Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
DECIMAL or NUMERIC:
- Precision: Up to 65 digits
- Scale: Up to 30 digits
FLOAT:
- Size: 4 bytes
- Precision: 7 digits
REAL:
- Size: 4 bytes
- Precision: 7 digits
DOUBLE or DOUBLE PRECISION:
- Size: 8 bytes
- Precision: 15 digits
Character String Data Types:
CHAR(n):
- Size: Fixed length of
n
characters.
- Size: Fixed length of
VARCHAR(n):
- Size: Variable length up to
n
characters. - Range: 1 to 65,535 bytes.
- Size: Variable length up to
TEXT:
- Size: Variable length.
- Range: 1 to 65,535 bytes.
Date and Time Data Types:
DATE:
- Size: 3 bytes
TIME:
- Size: 3 bytes
DATETIME:
- Size: 8 bytes
TIMESTAMP:
- Size: 4 bytes
Boolean Data Type:
- BOOLEAN or BOOL:
- Values: TRUE, FALSE, or NULL
Binary Data Types:
BINARY(n):
- Size: Fixed length of
n
bytes.
- Size: Fixed length of
VARBINARY(n):
- Size: Variable length up to
n
bytes. - Range: 1 to 65,535 bytes.
- Size: Variable length up to
BLOB:
- Size: Variable length.
- Range: 1 to 65,535 bytes.
Miscellaneous Data Types:
ENUM:
- Size: 1 or 2 bytes, depending on the number of enumeration values.
SET:
- Size: 1, 2, 3, 4, or 8 bytes, depending on the number of set members.
JSON:
- Size: Variable length.
Comments
Post a Comment