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()函数的更多相关文章

  1. Oracle管道函数(Pipelined Table Function)介绍

    一 概述: 1.管道函数即是能够返回行集合(能够使嵌套表nested table 或数组 varray)的函数,我们能够像查询物理表一样查询它或者将其  赋值给集合变量. 2.管道函数为并行运行,在普 ...

  2. Oracle中使用Table()函数解决For循环中不写成 in (l_idlist)形式的问题

    转: Oracle中使用Table()函数解决For循环中不写成 in (l_idlist)形式的问题 在实际PL/SQL编程中,我们要对动态取出来的一组数据,进行For循环处理,其基本程序逻辑为: ...

  3. Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace

    Oracle正则表达式函数:regexp_like.regexp_substr.regexp_instr.regexp_replace   --去掉所有特殊字符,只剩字母  SELECT REGEXP ...

  4. Oracle中函数/过程返回结果集的几种方式

    原文 Oracle中函数/过程返回结果集的几种方式 Oracle中函数/过程返回结果集的几种方式:    以函数return为例,存储过程只需改为out参数即可,在oracle 10g测试通过.    ...

  5. 十、oracle 常用函数

    一.字符函数字符函数是oracle中最常用的函数,我们来看看有哪些字符函数:lower(char):将字符串转化为小写的格式.upper(char):将字符串转化为大写的格式.length(char) ...

  6. oracle 常用函数汇总

    一.字符函数字符函数是oracle中最常用的函数,我们来看看有哪些字符函数:lower(char):将字符串转化为小写的格式.upper(char):将字符串转化为大写的格式.length(char) ...

  7. Oracle分析函数——函数列表

    --------------聚合函数 SUM :该函数计算组中表达式的累积和 MIN :在一个组中的数据窗口中查找表达式的最小值 MAX :在一个组中的数据窗口中查找表达式的最大值 AVG :用于计算 ...

  8. Oracle中函数/过程返回多个值(结果集)

    Oracle中函数/过程返回结果集的几种方式: 以函数return为例,存储过程只需改为out参数即可,在oracle 10g测试通过. (1) 返回游标: return的类型为:SYS_REFCUR ...

  9. Oracle开窗函数笔记及应用场景

    介绍Oracle的开窗函数之前先介绍一下分析函数,因为开窗函数也属于分析函数 分析函数用于计算基于组的某种聚合值,它和聚合函数的不同之处是:对于每个组返回多行,而聚合函数对于每个组只返回一行. 上面是 ...

随机推荐

  1. netty系列之:对聊天进行加密

    目录 简介 PKI标准 各类证书的后缀和转换 netty中启动SSL server netty中启动SSL client 总结 简介 在之前的文章中,我们讲到了怎么使用netty建立聊天室,但是这样的 ...

  2. 慕慕生鲜上线&&腾讯云服务器配置准备

    1.购买服务器并配置环境 1.1 购买 618购买了腾讯云服务器三年最低配置(1核2G 1Mbps 50G云盘),一时激动忘记了购买前领优惠券,痛失25元. 1.2 环境配置 系统是 CentOS L ...

  3. Go连接到Linux服务器进行操作-执行shell命令&&上传文件

    Go连接到Linux服务器进行操作 使用密码连接Linux服务器 package main import ( "fmt" "golang.org/x/crypto/ssh ...

  4. CobaltStrike去除流量特征

    CobaltStrike去除流量特征 ​普通CS没有做流量混淆会被防火墙拦住流量,所以偶尔会看到CS上线了机器但是进行任何操作都没有反应.这里尝试一下做流量混淆.参考网上的文章,大部分是两种方法,一种 ...

  5. OSI网络参考模型学习

    文章目录 一.计算机与网络的发展 1.1 批处理系统 1.2 分时系统 1.3 计算机之间的通信 1.4 基于分组交换技术的计算机网络 1.5 互联网时代的计算机网络 1.6 计算机网络中协议的规定 ...

  6. noip14

    T1 考试假贪心,20pts,能摧毁就摧毁,不管前边已经摧毁的水晶. 正解: 首先肯定要离散化,然后考虑dp,设 \(dp_{i,j}\) 表示当前处理到了i,摧毁掉的水晶的a最小为j,则转移方程: ...

  7. Docker开启TLS和CA认证

    前言:Docker直接开启2375端口是不安全的,别人只要连上之后就可以任意操作,下面是开启Docker的TLS和CA认证方法,并使用Jenkins和Portainer连接. 一.生成证书 查看服务器 ...

  8. springMVC学习日志一

    一.springMVC流程图省略 二.写一个简单的springmvc的demo来说明 2.1引入springMVC相关的jar包 2.2配置DispatcherServlet 在web.xml < ...

  9. windows编译boost

    1. https://www.boost.org 下载boost源码 boost_1_73_0.zip解压. 2.准备编译前的配置,打开vs2017 x86 CMD工具,进入目录boost_1_73_ ...

  10. gdb调试用命令与一般调试方法

    示例代码 1 #include <iostream> 2 using namespace std; 3 4 void Print() 5 { 6 cout<<"hel ...