oracle_loader类型外部表
1、创建目录(create any directory): SQLgt; create user Oracle identified by oracle; 用户已创建。 SQLgt; grant dba to
1、创建目录(create any directory):
SQL> create user Oracle identified by oracle;
用户已创建。
SQL> grant dba to oracle;
授权成功。
SQL> grant create any directory to oracle;
授权成功。
SQL> conn oracle/oracle
已连接。
2、创建外部表:
SQL> select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
-------------------- ---------------------------------------- -------------------------------------------
--
SYS ADMIN_DIR C:\ADE\aime_vista_ship\oracle/md/admin
SYS DATA_PUMP_DIR d:\oracle\product\10.2.0\admin\orcl\dpdump\
SYS BDUMP D:\oracle\product\10.2.0\admin\orcl\bdump
SYS WORK_DIR C:\ADE\aime_vista_ship\oracle/work
SQL> create table alert_log(text varchar2(400))
2 organization external (
3 type oracle_loader
4 default directory BDUMP
5 access parameters(
6 records delimited by newline
7 nobadfile
8 nodiscardfile
9 nologfile
10 )
11 location('alert_orcl.log')
12 )
13 reject limit unlimited
14 /
表已创建。
SQL> select * from alert_log where rownum
TEXT
------------------------------------------------------------------
Dump file d:\oracle\product\10.2.0\admin\orcl\bdump\alert_orcl.log
Sun May 16 11:25:15 2010
ORACLE V10.2.0.3.0 - Production vsnsta=0
vsnsql=14 vsnxtr=3
Windows NT Version V6.0
CPU : 2 - type 586
Process Affinity : 0x00000000
Memory (Avail/Total): Ph:372M/1021M
Sun May 16 11:25:15 2010
已选择9行。
3、外部表acess paramter获得方式
sqlldr oracle/oracle control=user.ctl external_table=generate_only
eg:
1、user.ctl(语法 可以使用EM DBCONSOLE生成) :
load
infile 'D:\oracle_file\data.txt'
badfile 'D:\oracle_file\data.bad'
discardfile 'D:\oracle_file\data.dis'
errors=50
append
into table user_data
fields terminated by ',' optionally enclosed by '"'
trailing nullcols
(user_name varchar2(20),
user_id number)
2、sqlldr oracle/oracle control=user.ctl external_table=generate_only log=user_data.log
你会在日志中发现:
文件需要 CREATE DIRECTORY 语句
------------------------------------------------------------------------
CREATE DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000 AS 'D:\oracle_file\'
用于外部表的 CREATE TABLE 语句:
------------------------------------------------------------------------
CREATE TABLE "SYS_SQLLDR_X_EXT_USER_DATA"
(
"USER_NAME" VARCHAR2(20),
"USER_ID" NUMBER
)
ORGANIZATION external
(
TYPE oracle_loader
DEFAULT DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE CHARACTERSET ZHS16GBK
BADFILE 'SYS_SQLLDR_XT_TMPDIR_00000':'data.bad'
DISCARDFILE 'SYS_SQLLDR_XT_TMPDIR_00000':'data.dis'
LOGFILE 'user_data.log_xt'
READSIZE 1048576
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
(
"USER_NAME" CHAR(255)
TERMINATED BY "," OPTIONALLY ENCLOSED BY '"',
"USER_ID" CHAR(255)
TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
)
)
location
(
'data.txt'
)
)REJECT LIMIT UNLIMITED
上一篇: HBase 的regioninfo
下一篇: Android面试系列—目录
推荐阅读
-
在Oracle的函数中,返回表类型的语句
-
Sqlserver 表类型和表变量介绍
-
《高性能MySQL》笔记——MySQL建表数据类型的选择
-
SQLSERVER查询锁表,阻塞,使用表名查询存储过程,行数,表字段类型等常规查询实例讲解
-
使用表类型(Table Type-SqlServer)实现百万级别的数据一次性毫秒级别插入
-
Oracle之表空间的概念、类型及实例讲解
-
java,hibernate和sqlserver对应的数据类型表
-
[一]class 文件浅析 .class文件格式详解 字段方法属性常量池字段 class文件属性表 数据类型 数据结构
-
SQL Server数据库、表、数据类型基本概念
-
C语言的符号表和类型系统1