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
TINYINTtype column:
- Query data from a
TINYINTtype column: - Using
TINYINTtype columns for conditional queries:
TINYINTconstant format:
Notes
- The
TINYINTtype is only suitable for storing smaller integer values. For larger values, it is recommended to use theINTorBIGINTtype. - When using the
TINYINTtype 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
TINYINTtype 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.
