TINYINT
TINYINT
is an 8-bit signed integer data type used to store integer values ranging from -128 to 127. It can efficiently save storage space as it only uses one byte to represent the value.
Syntax
Example
- Create a table with a
TINYINT
type column:
- Query data from a
TINYINT
type column: - Using
TINYINT
type columns for conditional queries:
TINYINT
constant format:
Notes
- The
TINYINT
type is only suitable for storing smaller integer values. For larger values, it is recommended to use theINT
orBIGINT
type. - When using the
TINYINT
type to store negative numbers, the range is -128 to -1. Attempting to insert a negative number outside this range will result in an overflow error. - When using the
TINYINT
type to store positive numbers, the range is 1 to 127. Attempting to insert a positive number outside this range will result in an overflow error.