Integer Data Types

From InterBase
Jump to: navigation, search

Go Up to Defining Numeric Data Types


Integers are whole numbers. InterBase supports two integer data types: ­SMALLINT and INTEGER. SMALLINT is a signed short integer with a range from –32,768 to 32,767. INTEGER is a signed long integer with a range from –2,147,483,648 to 2,147,483,647. Both are exact numerics.

The next two statements create domains with the SMALLINT and INTEGER data types:

CREATE DOMAIN EMPNO
 AS SMALLINT;
CREATE DOMAIN CUSTNO
 AS INTEGER
 CHECK (VALUE > 99999);

You can perform the following operations on the integer data types:

  • Comparisons using the standard relational operators (=, <, >, >=, <=). Other operators such as CONTAINING, STARTING WITH, and LIKE perform string comparisons on numeric values.
  • Arithmetic operations. The standard arithmetic operators determine the sum, difference, product, or dividend of two or more integers.
  • Conversions. When performing arithmetic operations that involve mixed data types, InterBase automatically converts between ­INTEGER, FLOAT, and CHAR data types. For operations that involve comparisons of numeric data with other data types, InterBase first converts the data to a numeric type, then performs the arithmetic operation or comparison.
  • Sorts. By default, a query retrieves rows in the exact order that it finds them in the table, which is likely to be unordered. You can sort rows using the ORDER BY clause of a SELECT statement in descending or ascending order.

Advance To: