PL/SQL data type

Source: Internet
Author: User

1. Variables and Constants
Variable syntax: variable_name data_type [[Not NULL] [: =value]
Description: NOT NULL defines a non-null constraint on a variable, a variable must be assigned a non-null initial value, and its value is not allowed to be modified to null at any time.

--Examples of variables:

Sql>serverout onsql>declare v_num Number (4);  BEGIN v_num:=20; Dbms_output. The value of put_line (' variable name v_num is: ' | | V_num); END; /

Constant syntax: Constant_name constant Data_type [: =value]

--Examples of constants:

DECLARE c_num CONSTANT Number (4): = 100; BEGIN Dbms_output. The value of Put_Line (' Constant name c_num: ' | | C_num); END;

2. Composite data type

2.1%type Type

The type of a column that references a variable or database is used as the data type of a variable.

SET serverout ondeclare v_ename scott.emp.ename%type;    V_sal1 number (11); V_sal2 V_sal1%type;    BEGIN SELECT ename,sal to V_ename,v_sal1 from Scott.emp WHERE empno=7369;    V_sal2:=v_sal1; Dbms_output. Put_Line (v_ename| | ' The wages are ' | | V_SAL2); END

2.2%rowtype

Refers to a row in a database table as the data type, that is, the record type, which is the additional type of PL/SQL. Represents a record, equivalent to an object in Java. You can use the "." To access the properties in the record.

This article from "It Technology Learning and communication" blog, declined reprint!

PL/SQL data type

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.