SQL Keywords

SQL INT8

What is SQL INT8?

INT8 is an 8-byte (64-bit) signed integer data type, an alias of BIGINT in PostgreSQL and several other systems.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL INT8: PostgreSQL (native), Amazon Redshift (alias), SQLite (accepted but dynamic), DuckDB (alias), ClickHouse (Int64). Not directly supported in MySQL, MariaDB, SQL Server, or Oracle; use BIGINT there.

SQL INT8 Full Explanation

INT8 stores whole numbers from −9 223 372 036 854 775 808 to 9 223 372 036 854 775 807 using 8 bytes of storage. In PostgreSQL it is a direct synonym for BIGINT, while other databases may recognize only BIGINT or support INT8 through ODBC compatibility layers. INT8 supports standard arithmetic, comparison, aggregate, and index operations. When values exceed the range, the database raises an overflow error. Because INT8 is strictly integer, fractional input is truncated or rejected depending on the dialect. INT8 columns can be indexed efficiently and often serve as primary keys, counters, monetary amounts stored in the smallest currency unit, or Unix epoch timestamps when millisecond precision is not required. 64-bit integers consume twice the space of INT4 but offer a vastly larger range. Some dialects (MySQL, SQL Server) do not accept the INT8 keyword; use BIGINT instead. SQLite accepts INT8 in a column declaration but internally stores values as dynamic-typed INTEGERs up to 8 bytes.

SQL INT8 Syntax

-- Column definition
column_name INT8 [NOT NULL] [DEFAULT value];

-- Cast expression
CAST(expression AS INT8);

SQL INT8 Parameters

Example Queries Using SQL INT8

-- Create a table using INT8 columns
CREATE TABLE orders (
    id INT8 PRIMARY KEY,
    total_cents INT8 NOT NULL
);

-- Insert the maximum INT8 value
INSERT INTO orders (id, total_cents)
VALUES (9223372036854775807, 1500);

-- Cast a string to INT8
SELECT CAST('123456789012345' AS INT8) AS big_number;

Expected Output Using SQL INT8

  • Table orders is created
  • One row is inserted with id 9223372036854775807
  • The SELECT returns a single row where big_number equals 123456789012345

Use Cases with SQL INT8

  • Storing large auto-incrementing or UUID-mapped primary keys
  • Tracking monetary amounts in the smallest currency unit to avoid floating-point errors
  • Recording Unix epoch times in seconds or milliseconds
  • Counting events where totals can surpass INT4 limits
  • Handling sensor or telemetry data that generates very large integer readings

Common Mistakes with SQL INT8

  • Assuming INT8 means 8 bits instead of 8 bytes
  • Using INT8 in MySQL or SQL Server, where the keyword is not recognized (use BIGINT)
  • Inserting values outside the INT8 range, resulting in overflow errors
  • Expecting INT8 to store decimals or fractions
  • Forgetting that INT8 consumes more storage and cache than INT4 when the extra range is unnecessary

Related Topics

BIGINT, INT, INT4, SMALLINT, SERIAL8, NUMERIC, CAST

First Introduced In

PostgreSQL 6.1 (1997)

Frequently Asked Questions

What range does INT8 support?

INT8 handles any whole number between −9 223 372 036 854 775 808 and 9 223 372 036 854 775 807 inclusive.

Is INT8 the same as BIGINT?

In PostgreSQL and many analytical databases, INT8 is a direct alias for BIGINT, so they behave identically.

Why is INT8 not recognized in MySQL or SQL Server?

Those systems accept the BIGINT keyword instead. Replace INT8 with BIGINT for full compatibility.

How do I cast a value to INT8?

Use CAST(expression AS INT8) or the :: operator in PostgreSQL, for example: SELECT '42'::INT8;

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!