PL/SQL BASIC structure---basic data type variables

Source: Internet
Author: User

1. Basic data types
Number Type
int integer type
Pls_integer integer type, error occurred while generating overflow
Binary_integer integer that represents the signed integer
Char fixed-length, 255 characters maximum
Varchar2 variable length character, max 2000 characters
Long variable length character, up to 2GB
Date type
Boolean Boolean (TRUE, FALSE, null three take one)
The data types used in PL/SQL and the data types used in the Oracle database are identical in meaning and have different meanings.

 2. Basic data type variable definition method  
     variable name   type identifier   [not null]:= value;  
      declare 
         Age Number (3): = 26;--Length 3, The initial value is 26 
     begin 
         commit;  
     end; 
     The syntax format for defining constants:  
      constant Name   constant type identifier   [not null]:= value;  
     declare 
          PI constant Number (9): =3.1415926;--is a numeric constant of pi, length is 9, initial value is 3.1415926 
     begin 
         commit; 
     end; 

Variable declarations in PL/SQL
All variables must be declared in declare, and declarations are not allowed in the program.
The default value of a variable that is not initialized is null, and on-screen null is invisible, naming the habit: A variable in PL/SQL typically begins with v_ (the equivalent of a variable defined by the AS and begin regions in a stored procedure).
Note that number can also be stored in decimals, up to 38 bits, so it is recommended that integers be saved with Binary_integer.
Long is a character type and the Boolean type cannot print.
Standard variable type: number, character, time, Boolean.

PL/SQL BASIC structure---basic data type variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.