INT8

INT8 is a data type in SQL, specifically employed in PostgreSQL. It stands for 8-byte integer and it stores whole numbers, positive or negative, without decimal points. The range of values for INT8 is -9223372036854775808 to 9223372036854775807.

Example

CREATE TABLE Test (
ID INT8 PRIMARY KEY
);
INSERT INTO Test (ID)
VALUES (123456789012345);
SELECT * FROM Test;

Output

ID
-----------
123456789012345

Explanation

An INT8 column was created in the Test table. The value 123456789012345 was inserted into the ID column of the Test table. The SELECT statement was then used to return the inserted value.

Example

DECLARE @MyVar INT;
SET @MyVar = 255;
SELECT @MyVar AS 'INT8 Value';

Output

INT8 Value
255

Explanation

In the example, an integer variable @MyVar is declared and assigned a value of 255. The SELECT statement is then used to return the value of @MyVar, displaying ‘255’. Note that the INT8 datatype is not explicitly used in SQL Server. The equivalent data type in SQL Server is INT, which has a storage size of 4 bytes and a range from -2,147,483,648 to 2,147,483,647. The INT data type was used here to represent INT8. The INT8 terminology is often used in reference to programming languages like C and Java, where it represents an 8 bit signed integer, but it’s not used in the context of SQL Server. SQL does not recognize INT8 as a valid datatype.

Oracle does not support an INT8 data type directly. However, the NUMBER data type can be used to essentially achieve the same kind of functionality. The NUMBER data type has a precision of 38 decimal digits, and it can be used to store both integer and real numbers.

Example

Database setup:

CREATE TABLE test_table (num NUMBER(19,0));

Inserting data into the table:

INSERT INTO test_table (num) VALUES (1234567890123456789);
COMMIT;

Output

Querying the data:

SELECT num FROM test_table;

The above query will display the inserted number:

1234567890123456789

Explanation

In the provided example, a table named test_table was created with a single column num of type NUMBER. The precision of 19 was specified, which allows the column to hold any integer value up to 19 digits long. The number 1234567890123456789 was then inserted into the table. When the database was queried, it returned the inserted number.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.