Thursday, 25 June 2015

Datatypes in Oracle PL/SQL



A scalar data type can have subtypes. A subtype is a data type that is a subset of another data type, which is its base type. A subtype has the same valid operations as its base type. A data type and its subtypes comprise a data type family.
PL/SQL predefines many types and subtypes in the package STANDARD and lets you define your own subtypes.
The PL/SQL scalar data types are:
  •          The SQL data types
  •          BOOLEAN
  •          PLS_INTEGER
  •          BINARY_INTEGER
  •          REF CURSOR
  •          User-defined subtypes


BOOLEAN:
                We cannot pass a Boolean value to DBMS_OUTPUT.PUT or DBMS_OUTPUT.PUT_LINE functions. To print Boolean value, we need to use CASE or IF Statement.
PLS_INTEGER & BINARY_INTEGER:
                PLS_INTEGER requires less storage
                PLS_INTEGER uses hardware arithmetic, so they are faster than NUMBER operations, which uses Library Arithmetic
                SIMPLE _INTEGER is the sub type of PLS_INTEGER . Is it the PLS_INTEGER value with NOT NULL constraint
                BINARY_INTEGER is the subtype of NUMBER, which uses Library Arithmetic
                Predefined PLS_INTEGER Subtypes are
  •          NATURAL
  •          NATURALN
  •          POSITIVE
  •          POSITIVEN
  •          SIMPLE_INTEGER



No comments:

Post a Comment