Integer
Integer data types are designed to store whole numbers.
For more information about identity sequences (sometimes called auto-increment or auto-numbers), see Identity.
Integer Types
The following table describes the Integer types.
Name |
Details |
Data Size (Not Null, Uncompressed) |
Example |
---|---|---|---|
|
Unsigned integer (0 - 255) |
1 byte |
|
|
Integer (-32,768 - 32,767) |
2 bytes |
|
|
Integer (-2,147,483,648 - 2,147,483,647) |
4 bytes |
|
|
Integer (-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807) |
8 bytes |
|
The following table describes the Integer data type.
Syntax |
Data Size (Not Null, Uncompressed) |
---|---|
An integer can be entered as a regular literal, such as |
Integer types range between 1, 2, 4, and 8 bytes - but resulting average data sizes could be lower after compression. |
Integer Examples
The following is an example of the Integer syntax:
CREATE TABLE cool_numbers (a INT NOT NULL, b TINYINT, c SMALLINT, d BIGINT);
INSERT INTO cool_numbers VALUES (1,2,3,4), (-5, 127, 32000, 45000000000);
SELECT * FROM cool_numbers;
The following is an example of the correct output:
1,2,3,4
-5,127,32000,45000000000
Integer Casts and Conversions
The following table shows the possible Integer value conversions:
Type |
Details |
---|---|
|
|
|
|