Oracle PL/SQL - BINARY_INTEGER Type

Introduction

BINARY_INTEGER data type and PLS_INTEGER data type works in a similar way.

A simple declaration of these data types is shown here:

declare
      variable1_nr BINARY_INTEGER;
      variable2_nr PLS_INTEGER;

These data types are interchangeable.

Both of these data types exist only in PL/SQL, and you cannot create a column of these types.

BINARY_INTEGER variables are between -2^31 and 2^31.

2^31 = 2,147,483,648.

Demo

SQL>
SQL> set timing on-- from  www  .  j a  va 2 s. c om
SQL> declare
  2      v_nr number;
  3  begin
  4      for i in 1..1000000 loop
  5          v_nr:=v_nr+i-i+i*2-i*2;
  6      end loop;
  7  end;
  8  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.17
SQL>
SQL> declare
  2       v_nr binary_integer;
  3  begin
  4       for i in 1..1000000 loop
  5           v_nr:=v_nr+i-i+i*2-i*2;
  6       end loop;
  7  end;
  8  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.09
SQL>

Related Topic