oracle external table
来源:互联网 发布:淘宝联盟如何注册账号 编辑:程序博客网 时间:2024/04/20 04:10
外部表是存储于数据库外的一种表,它允许以只读的形式读取外部表里的数据. 你可以像普通表一样对外部表进行SELECT, SORT, JOIN操作,也可以在外部表上建视图,同义词等,但不能有DML操作,不能创建索引。
生成外部表时,会在目录下自动生成日志文件。
生成的外部表并不是实际存在,不会占用存储空间。
创建外部表
using:CREATE TABLE...ORGANIZATION EXTERNAL
type - 指定外部表的类型。两个可用类型是ORACLE_LOADER类型和ORACLE_DATAPUMP类型。每种类型的外部表是由它自己的访问驱动程序所支持。ORACLE_LOADER:默认,只能从外部表到内部表,数据来源是文本文件
ORACLE_DATAAPUMP:可以从外部表到内部表,也可从内部表到外部表,数据源只能是二进制文件.
default directory: 加载或卸载的默认目录,指的是directory 对象,而不是物理路径
location: 数据文件名,格式directory:file direcotry 如果没有显式指明,默认 default_directory
e.g 使用ORACLE_LOADER导入数据文件
在E:/oracle/data目录下新建
ex1.txt
1,hello
2,wuhen
2,wuhen
ex2.txt
3,hello
4,world
4,world
create directory wuhen as 'E:/oracle/data'; --创建目录对象
grant read,write on drirectory wuhen to wuhen; --授权
create table ex_t1 --创建外部表
(c1 varchar2( 5),c2 varchar2 (20))
organization external
(
type oracle_loader
default directory wuhen --指定外部表的存放目录
access parameters (records delimited by newline
fields terminated by ','
)
/*
records delimited 读取记录,默认by newline,以换行符为一记录
fields terminated by ',' 读取字段,默认 by ',',以逗号为字段分隔
*/
location('ex1.txt' ,'ex2.txt') --数据文件,在默认目录下,可有多个文件
);
验证
SQL> select * from ex_t1;
C1 C2
----- --------------------
1 hello
2 wuhen
3 hello
4 world
e.g 使用ORACLE_DATAPUMP 导出数据文件
create table ex_t3(c1,c2,c3) --创建外部表
organization external
(
type oracle_datapump
default directory wuhen
ACCESS PARAMETERS (nologfile)
/*
nogfile 不生成日志文件,此处也可LOGFILE wuhen:ex_t3 指定日志文件位置,在wuhen目录对象下生成ex_t3.log
11g 还有 COMPRESSION [ENABLED | DISABLED]指定是否对数据进行压缩
ENCRYPTION [ENABLED | DISABLED] 指定是否对数据进行加密
*/
location ('ex3.dmp' ))
as
select username,user_id,password from dba_users where rownum < 3;
验证
select * from ex_t3;
C1 C2 C3
------------------------------ ---------- ------------------------------
MGMT_VIEW 57 A9C0D2A4F6B75CBC
SYS 0 262FBDE157DFFFA5
0 0
- Oracle External Table (1)
- oracle外表(external table)
- oracle external table
- Oracle external table
- Oracle外部表 External Table
- Oracle external table & SQL*Loader
- Oracle External Table Population小记
- Oracle外部表 External Table
- oracle 外部表 external table
- external table sample : from oracle document
- Oracle 之 外部表 external table
- oracle中创建外表(external table)
- 学习掌握oracle外表(external table)
- external table
- external table
- Oracle中的external table和 materialized view学习
- Oracle 外部表 External Table(一)[转+实践]
- Using Oracle Data Pump to create an external table
- 40个良好的用户界面Tips
- U3D实现键盘控制物体方向
- scrapy 安装步骤
- 关于表空间命令
- Cordys Xform开发注意点
- oracle external table
- Java远程调试
- hdu5316 Magician(线段树区间合并)
- 省市县联查 三级联动
- Hadoop运行wordcount出现“JobTracker is not yet RUNNING”
- 49.PushmeBaby发布模式生产模式-OTA发布app 时候 push不显示问题
- 让进程在后台可靠运行的几种方法
- HDU 3345 war chess(bfs + 优先队列)
- 支持Android4.0以下webp的使用