侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

临时表,外部表

2023-12-05 星期二 / 0 评论 / 0 点赞 / 93 阅读 / 2820 字

1 临时表 1.1居于事物的临时表 create global temporary table table_name (column datatype) on commit delete row

1    临时表

        1.1 居于事物的临时表

         create global temporary table table_name (column datatype) on commit delete rows;

# 创建一个临时表create global temporary table tmp_temporary_t1(name varchar2(20), sal number ) on commit delete rows;# 插入数据 insert into tmp_temporary_t1 select 'a',200 from dual;# 检查数据NAME	SALa	200# 提交数据再检查 commit;  select * from tmp_temporary_t1;# 提交后就没有数据了。

        1.2 居于会话的临时表
            create global temporary table table_name(column datatype) on commit preserve rows;

        1.3 普通临时表
            create gloabl temporary table table_name(column datatype);
            需要手动清理里面的数据,默认数据是放在临时表空间里面。

  create global temporary table tmp_global_t1  (id number,   age number   );

2    外部表

外部表:数据不是存放在数据库中,而是存放在某个文件中,并且对数据查询的时候引入数据库不占用空间
sqlloader 工具值在sqlplus 导入 将外部数据文件导入,加载文本文件
oracle loader 工具引用外部表,但是不存入数据库存入外部文件,且只能加载二进制文件
oracle datapump

    2.1 先建一个表

create table tmp_out_table_1(loc varchar2(50), numb number );

    2.2 把数据存放在文件中

[root@myyun1 tmp]# cat 1.txtzhang,1wang,2li,3zhao,4

    2.3 创建一个控制文件ins.ctl

            控制文件名字自己随便定义后缀为ctl

[root@myyun1 tmp]# cat ins.ctl load datainfile '/tmp/1.txt'into table tmp_out_table_1truncateFIELDS TERMINATED BY ','trailing nullcols(loc,numb)

            运行控制文件

[root@myyun1 oracle]# sqlldr scott/tiger control=/tmp/ins.ctlSQL*Loader: Release 11.2.0.3.0 - Production on Fri Dec 9 20:58:16 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.Commit point reached - logical record count 4# 检查导入的文件select * from tmp_out_table_1;LOC	NUMBzhang	1wang	2li	3zhao	4# 文件导入成功

 

广告 广告

评论区