oracle table()函数
PL/SQL表---table()函数用法
/*
PL/SQL表---table()函数用法:
利用table()函数,我们可以将PL/SQL返回的结果集代替table。
oracle内存表在查询和报表的时候用的比较多,它的速度相对物理表要快几十倍。
simple example:
1、table()结合数组:
*/
create or replace type t_test as object(
id integer,
rq date,
mc varchar2(60)
);
create or replace type t_test_table as table of t_test;
create or replace function f_test_array(n in number default null) return t_test_table
as
v_test t_test_table := t_test_table();
begin
for i in 1 .. nvl(n,100) loop
v_test.extend();
v_test(v_test.count) := t_test(i,sysdate,'mc'||i);
end loop;
return v_test;
end f_test_array;
/
select * from table(f_test_array(10));
select * from the(select f_test_array(10) from dual);
/*
2、table()结合PIPELINED函数:
*/
create or replace function f_test_pipe(n in number default null) return t_test_table PIPELINED
as
v_test t_test_table := t_test_table();
begin
for i in 1 .. nvl(n,100) loop
pipe row(t_test(i,sysdate,'mc'||i));
end loop;
return;
end f_test_pipe;
/
select * from table(f_test_pipe(20));
select * from the(select f_test_pipe(20) from dual);
/*
3、table()结合系统包:
*/
create table test (id varchar2(20));
insert into test values('1');
commit;
explain plan for select * from test;
select * from table(dbms_xplan.display);
PL/SQL表---table()函数用法
/*
PL/SQL表---table()函数用法:
利用table()函数,我们可以将PL/SQL返回的结果集代替table。
oracle内存表在查询和报表的时候用的比较多,它的速度相对物理表要快几十倍。
simple example:
1、table()结合数组:
*/
create or replace type t_test as object(
id integer,
rq date,
mc varchar2(60)
);
create or replace type t_test_table as table of t_test;
create or replace function f_test_array(n in number default null) return t_test_table
as
v_test t_test_table := t_test_table();
begin
for i in 1 .. nvl(n,100) loop
v_test.extend();
v_test(v_test.count) := t_test(i,sysdate,'mc'||i);
end loop;
return v_test;
end f_test_array;
/
select * from table(f_test_array(10));
select * from the(select f_test_array(10) from dual);
/*
2、table()结合PIPELINED函数:
*/
create or replace function f_test_pipe(n in number default null) return t_test_table PIPELINED
as
v_test t_test_table := t_test_table();
begin
for i in 1 .. nvl(n,100) loop
pipe row(t_test(i,sysdate,'mc'||i));
end loop;
return;
end f_test_pipe;
/
select * from table(f_test_pipe(20));
select * from the(select f_test_pipe(20) from dual);
/*
3、table()结合系统包:
*/
create table test (id varchar2(20));
insert into test values('1');
commit;
explain plan for select * from test;
select * from table(dbms_xplan.display);
oracle table()函数的更多相关文章
- Oracle管道函数(Pipelined Table Function)介绍
一 概述: 1.管道函数即是能够返回行集合(能够使嵌套表nested table 或数组 varray)的函数,我们能够像查询物理表一样查询它或者将其 赋值给集合变量. 2.管道函数为并行运行,在普 ...
- Oracle中使用Table()函数解决For循环中不写成 in (l_idlist)形式的问题
转: Oracle中使用Table()函数解决For循环中不写成 in (l_idlist)形式的问题 在实际PL/SQL编程中,我们要对动态取出来的一组数据,进行For循环处理,其基本程序逻辑为: ...
- Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
Oracle正则表达式函数:regexp_like.regexp_substr.regexp_instr.regexp_replace --去掉所有特殊字符,只剩字母 SELECT REGEXP ...
- Oracle中函数/过程返回结果集的几种方式
原文 Oracle中函数/过程返回结果集的几种方式 Oracle中函数/过程返回结果集的几种方式: 以函数return为例,存储过程只需改为out参数即可,在oracle 10g测试通过. ...
- 十、oracle 常用函数
一.字符函数字符函数是oracle中最常用的函数,我们来看看有哪些字符函数:lower(char):将字符串转化为小写的格式.upper(char):将字符串转化为大写的格式.length(char) ...
- oracle 常用函数汇总
一.字符函数字符函数是oracle中最常用的函数,我们来看看有哪些字符函数:lower(char):将字符串转化为小写的格式.upper(char):将字符串转化为大写的格式.length(char) ...
- Oracle分析函数——函数列表
--------------聚合函数 SUM :该函数计算组中表达式的累积和 MIN :在一个组中的数据窗口中查找表达式的最小值 MAX :在一个组中的数据窗口中查找表达式的最大值 AVG :用于计算 ...
- Oracle中函数/过程返回多个值(结果集)
Oracle中函数/过程返回结果集的几种方式: 以函数return为例,存储过程只需改为out参数即可,在oracle 10g测试通过. (1) 返回游标: return的类型为:SYS_REFCUR ...
- Oracle开窗函数笔记及应用场景
介绍Oracle的开窗函数之前先介绍一下分析函数,因为开窗函数也属于分析函数 分析函数用于计算基于组的某种聚合值,它和聚合函数的不同之处是:对于每个组返回多行,而聚合函数对于每个组只返回一行. 上面是 ...
随机推荐
- 开源爆款,阿里P7Android技术笔记,理论与实战齐飞,限时开放下载!
自我介绍 2013年java转到Android开发,在小厂待过,也去过华为,OPPO等大厂待过,18年四月份进了阿里一直到现在. 被人面试过,也面试过很多人.深知大多数初中级Android工程师,想要 ...
- java 注释,关键字和标识符
注释 注释是为了防止当写代码的时间过久了之后,忘记了这行代码的意思或者是在一个大型的项目里面,不可能每一个模块的功能你都记得,所以需要一个注释来帮助记忆. 注释不会被执行 平时写代码一定要养成写注释的 ...
- Note about Cobertura
Workflow of Unit Test without Cobertura compile source code; compile test code; run unit test; Workf ...
- SpringBoot开发十六-帖子详情
需求介绍 实现帖子详情,在帖子标题上增加访问详情页面的链接. 代码实现 开发流程: 首先在数据访问层新增一个方法 实现查看帖子的方法 业务层同理增加查询方法 最后在表现层处理查询请求 数据访问层增加根 ...
- [源码解析] 机器学习参数服务器Paracel (3)------数据处理
[源码解析] 机器学习参数服务器Paracel (3)------数据处理 目录 [源码解析] 机器学习参数服务器Paracel (3)------数据处理 0x00 摘要 0x01 切分需要 1.1 ...
- SeacmsV10.7版代码审计笔记
data: 2020.11.9 10:00AM description: seacms代码审计笔记 0X01前言 seacms(海洋cms)在10.1版本后台存在多处漏洞,事实上当前最新版V10.7这 ...
- NGINX-1.6.3部署详情
Nginx_沁贰百科 介绍 Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Ra ...
- 超详细,自动化测试接入Jenkins+Sonar质量门禁实践
大家好,我叫董鑫,一名在测试开发道路上的新手.第一阶段的学习已然结束,收获颇多,了解了很多在自己平时测试工作无法接触到的新知识,比如这次在这里分享的Sonarqube进行静态代码扫描并集成Jenkin ...
- NOIP 模拟 $17\; \rm weight$
题解 \(by\;zj\varphi\) 一道树剖的题 先对于原图求出一棵最小生成树,求出来的这棵树中的边定为树边,其它边叫非树边 那么对于一条非树边,它要成为最小生成树上的边,权值只能为连接它两个端 ...
- NPM使用方法
什么是npm npm是nodejs的包管理器,在当今工程化前端开发过程中,npm包起着举足轻重的作用. 安装npm 作为nodejs的包管理器,npm随着nodejs一起安装的.通常情况下,当我们安装 ...