Firebird 2.5 Language ReferenceFirebird 2.5 Language ReferenceData Types and Subtypes → Integer Data Types
Firebird Firebird Prev: Data Types and SubtypesFirebird 2.5 Language ReferenceUp: Data Types and SubtypesNext: Floating-Point Data Types

Integer Data Types

Table of Contents

SMALLINT
INTEGER
BIGINT
Hexadecimal Format for Integer Numbers

The SMALLINT, INTEGER and BIGINT data types are used for integers of various precision in Dialect 3. Firebird does not support an unsigned integer data type.

SMALLINT

The 16-bit SMALLINT data type is for compact data storage of integer data for which only a narrow range of possible values is required for storing them. Numbers of the SMALLINT type are within the range from -216 to 216 - 1, that is, from -32,768 to 32,767.

SMALLINT Examples: 

      CREATE DOMAIN DFLAG AS SMALLINT DEFAULT 0 NOT NULL
        CHECK (VALUE=-1 OR VALUE=0 OR VALUE=1);

      CREATE DOMAIN RGB_VALUE AS SMALLINT;
        

INTEGER

The INTEGER data type is a 32-bit integer. The shorthand name of the data type is INT. Numbers of the INTEGER type are within the range from -232 to 232 - 1, that is, from -2,147,483,648 to 2,147,483,647.

INTEGER Example: 

CREATE TABLE CUSTOMER (
  CUST_NO INTEGER NOT NULL, 
  CUSTOMER VARCHAR(25) NOT NULL, 
  CONTACT_FIRST VARCHAR(15), 
  CONTACT_LAST VARCHAR(20),
  ...
    PRIMARY KEY (CUST_NO) )
        

BIGINT

BIGINT is an SQL:99-compliant 64-bit integer data type, available only in Dialect 3. If a client uses Dialect 1, the generator value sent by the server is reduced to a 32-bit integer (INTEGER). When Dialect 3 is used for connection, the generator value is of type BIGINT.

Numbers of the BIGINT type are within the range from -263 to 263 - 1, or from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

Hexadecimal Format for Integer Numbers

Starting from Firebird 2.5, constants of the three integer types can be specified in hexadecimal format by means of 9 to 16 hexadecimal digits for BIGINT or 1 to 8 digits for INTEGER. Hex representation for writing to SMALLINT is not explicitly supported but Firebird will transparently convert a hex number to SMALLINT if necessary, provided it falls within the ranges of negative and positive SMALLINT.

The usage and numerical value ranges of hexadecimal notation are described in more detail in the discussion of number constants in the chapter entitled Common Language Elements.

Examples Using Integer Types: 

       CREATE TABLE WHOLELOTTARECORDS (
         ID BIGINT NOT NULL PRIMARY KEY,
         DESCRIPTION VARCHAR(32)
        );

       INSERT INTO MYBIGINTS VALUES (
         -236453287458723,
         328832607832,
         22,
         -56786237632476,
         0X6F55A09D42, -- 478177959234
         0X7FFFFFFFFFFFFFFF, -- 9223372036854775807
         0XFFFFFFFFFFFFFFFF, -- -1
         0X80000000, -- -2147483648, an INTEGER
         0X080000000, -- 2147483648, a BIGINT
         0XFFFFFFFF, -- -1, an INTEGER
         0X0FFFFFFFF -- 4294967295, a BIGINT
        );
        

The hexadecimal INTEGERs in the above example are automatically cast to BIGINT before being inserted into the table. However, this happens after the numerical value is determined, so 0x80000000 (8 digits) and 0x080000000 (9 digits) will be saved as different BIGINT values.

Prev: Data Types and SubtypesFirebird 2.5 Language ReferenceUp: Data Types and SubtypesNext: Floating-Point Data Types
Firebird 2.5 Language ReferenceFirebird 2.5 Language ReferenceData Types and Subtypes → Integer Data Types