易截截图软件、单文件、免安装、纯绿色、仅160KB

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 to_date,to_char,trunc,decode用法

select decode('X','Q','变量1','变量2') from dual
 select sysdate,to_char(sysdate,’yyyy-mm-dd hh24:mi:ss’) from dual
 
 select to_date(’2003-10-17 21:15:37’,’yyyy-mm-dd hh24:mi:ss’) from dual  
日期格式参数 含义说明
D 一周中的星期几
DAY 天的名 ......

oracle 逻辑备份命令EXP/IMP参数参考手册

oracle 逻辑备份命令EXP/IMP参数参考手册
帮助命令:exp help=y
Export: Release 10.2.0.1.0 - Production on Thu Jul 20 10:39:50 2006
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
 You can let Export prompt you for parameters by entering the EXP
command followed b ......

Oracle常用SQL语句(PL/SQL developer工具下的)

 建表
create table users(
id number(4) primary key,
username varchar2(10),
password varchar2(10)
)
查询表并解锁表(即可以点击输入框下面的"锁"图标工具, 即"Edit data")
select * from users for update
删除表中多余的列
alter table mobilephone drop column mobiletype
转载
------------------- ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号