Oracle9i + pl_ SQL Study Notes

Source: Internet
Author: User
Index Table
Index-by tables is a bit similar to a database table, which consists of two columns (key and value ). Its key value type is binary_integer, and value type is the type specified in the definition. Unlike a database table, it is a table stored in memory.
Define index table:
Type type_name is table of element_type [not null]
Index by binary_integer;
Type_name: name of the defined type, which declares the index table variable.
Element_type: Declares the Data Type of the value in the index table.
Not null is optional. If not null is specified, a null value cannot be inserted.
Index by binary_integer is used to mark the index table. If not, it is a nested table by default.
Type my_table is table of varchar2 (30) index by binary_integer;
V_mt my_table;
The value of the index table can be a scalar type or a record type.
Type mytable is table of Treader. % rowtype index of binary_integer;
Insert data to the index table
After defining the types and variables, you can use mytable [Key] to reference a single element in the index table. Mytable [Key]: = value.
Nested table
The nested table is similar to the index table. The difference is that the nested table can be saved to the database, but the index table cannot.
Declaration: Type type_name is table of element_type [not null]
Nested assignment:
Declare
Type test is table of varchar2 (10 );
Mt test: = test ('fan ', 'hao ');
Begin
Dbms_output.put_line (MT (1) | ''| MT (2 ));
End;
/

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.