ORACLE PL/SQL 集合学习笔记(二)
三、嵌套表的使用方法
1、将嵌套表定义为PL/SQL的程序构造块
TYPE type_name IS TABLE OF element_type[NOT NULL];
如下例所示:
DECLARE
-- Define a nested table of variable length strings.
TYPE card_table IS TABLE OF VARCHAR2(5 CHAR);
-- Declare and initialize a nested table with three rows.
cards CARD_TABLE := card_table(NULL,NULL,NULL);
BEGIN
-- Print title.
dbms_output.put_line(
'Nested table initialized as nulls.');
dbms_output.put_line(
'----------------------------------');
-- Loop through the three records.
FOR i IN 1..3 LOOP
-- Print the contents.
dbms_output.put ('Cards Varray ['||i||'] ');
dbms_output.put_line('['||cards(i)||']');
END LOOP;
-- Assign values to subscripted members of the varray.
cards(1) := 'Ace';
cards(2) := 'Two';
cards(3) := 'Three';
-- Print title.
dbms_output.put (CHR(10)); -- Visual line break.
dbms_output.put_line(
'Nested table initialized as Ace, Two and Three.');
dbms_output.put_line(
'-----------------------------------------------');
-- Loop through the three records to print the varray contents.
FOR i IN 1..3 LOOP
dbms_output.put_line('Cards ['||i||'] '
|| '['||cards(i)||']');
END LOOP;
END;
/
2、将嵌套表类型定义和用作PL/SQL的对象类型
CREATE OR REPLACE TYPE type_name
AS TABLE OF element_type [NOT NULL];
如下例所示:
-- Define a varray of four rows of variable length strings.
CREATE OR REPLACE TYPE card_unit_varray
AS VARRAY(13) OF VARCHAR2(5 CHAR);
/
-- Define a varray of four rows of variable length strings.
CREATE OR REPLACE TYPE card_suit_varray
AS VARRAY(4) OF VARCHAR2(8 CHAR);
/
-- Define a table of variable length strings.
CREATE OR REPLACE TYPE card_deck_table
AS TABLE OF VARCHAR2(17 CHAR);
/
DECLARE
-- Define a counter to manage 1 to 52 cards in a deck.
counter INTEGER
相关文档:
完全卸载Oracle方法:
软件环境:
1、Windows XP + Oracle 10g
2、Oracle安装路径为:d:\Oracle
1、如果数据库配置了自动存储管理(ASM),应该先删除聚集同步服务CSS(cluster Synchronization Services).删除CSS服务的方法是在DOS命令行中执行如下命令: localconfig delete
2、在“服务”窗口中停 ......
Imp和Exp
命令详解:
Exp
导出
模式:
Full模式---导出
整个数据库
User模式---导出
指定的用户
Table模式—导出
指定的表
Tablespace模式—导出
表
空间
Exp
导出
参数:
OWNER指定要导出
的用户列表
FULL=y表示要导出
整个数据库
Tables指定要导出
的表
Tablepaces指定要导出
的表
......
oracle% sqlplus /nolog
SQL> conn / as sysdba
数据库的物理文件
数据文件
select file_name from dba_data_files;
控制文件
select name from v$controlfile;
日志文件
select member from v$logfile;
---------------------------------------------------------
......
执行顺序:从左到右,变量优先,逐行更新
摘自CSDN的例子(http://topic.csdn.net/u/20091030/16/7fd75fa6-bdb9-4516-9b27-48aef69703ba.html
http://topic.csdn.net/u/20090904/16/e5dad9c7-fb59-41b9-b28d-e3b71c3e8420.html)
1.变量优先
create table #t (field1 varchar(10),field2 varchar(10))
insert #t sel ......
二、以形参的形式定义和使用记录、对象类型
在用作形式参数时,记录类型和对象类型有很多相同之处。在将它们作为游标、函数或过程的形式参数以前,事先都必须定义一个记录类型或者对象类型。
如下例所示:
记录
DECLARE
-- Define a record type.
TYPE individual_record IS RECORD
(individual_id ......