INT
INT is a 32-bit signed integer data type that occupies 4 bytes of storage and is the most commonly used integer type.
Syntax
Value Range
| Bound | Value |
|---|---|
| Minimum | -2,147,483,648 |
| Maximum | 2,147,483,647 |
Examples
-
Convert a string to INT:
Returns:
5 -
Integer literals and arithmetic operations:
Returns:
14 -
Convert integers to INT (boundary values):
Returns:
2147483647,-2147483648 -
Overflow behavior (out-of-range returns NULL):
Returns:
NULL -
Invalid string conversion returns NULL:
Returns:
NULL -
NULL value handling:
Returns:
NULL
Notes
- The value range is -2,147,483,648 to 2,147,483,647. CAST conversions that exceed the range return NULL without raising an error.
- For integers beyond the INT range, use
BIGINT. - CAST of an invalid string (e.g.,
'abc') returns NULL. - When INT participates in arithmetic operations, overflow may occur if the result exceeds the range. Consider casting to BIGINT first in scenarios where overflow is possible.
- When creating a table,
INTandINTEGERare equivalent.
