SQL*Loader: Release 10.2.0.1.0 - Production on Sat Jan 26 20:16:38 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: emp2xt.ctl Character Set ZHS16GBK specified for all input.
Data File: ./emp2xt.dat Bad File: emp2xt.bad Discard File: none specified (Allow all discards)
Number to load: ALL Number to skip: 0 Errors allowed: 50 Continuation: none specified Path used: External Table
Table EMP2XT, loaded from every logical record. Insert option in effect for this table: APPEND TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype ------------------------------ ---------- ----- ---- ---- --------------------- EMPNO FIRST * , O(") CHARACTER ENAME NEXT * , O(") CHARACTER JOB NEXT * , O(") CHARACTER MGR NEXT * , O(") CHARACTER HIREDATE NEXT * , O(") DATE DD-MM-YY NULL if HIREDATE = 0X4e554c4c(character 'NULL') SAL NEXT * , O(") CHARACTER COMM NEXT * , O(") CHARACTER DEPTNO NEXT * , O(") CHARACTER
CREATE DIRECTORY statements needed for files ------------------------------------------------------------------------ CREATE DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000 AS './'
CREATE TABLE statement for external table: ------------------------------------------------------------------------ CREATE TABLE "SYS_SQLLDR_X_EXT_EMP2XT" ( "EMPNO" NUMBER(4), "ENAME" VARCHAR2(10), "JOB" VARCHAR2(9), "MGR" NUMBER(4), "HIREDATE" DATE, "SAL" NUMBER(7,2), "COMM" NUMBER(7,2), "DEPTNO" NUMBER(2) ) ORGANIZATION external ( TYPE oracle_loader DEFAULT DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000 ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE CHARACTERSET ZHS16GBK BADFILE 'EXT_DIR':'emp2xt.bad' LOGFILE 'emp2xt.log_xt' READSIZE 1048576 FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM MISSING FIELD VALUES ARE NULL REJECT ROWS WITH ALL NULL FIELDS ( "EMPNO" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "ENAME" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "JOB" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "MGR" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "HIREDATE" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' DATE_FORMAT DATE MASK "DD-MM-YY" NULLIF ("HIREDATE" = "NULL"), "SAL" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "COMM" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "DEPTNO" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' ) ) location ( 'emp2xt.dat' ) )REJECT LIMIT UNLIMITED
INSERT statements used to load internal tables: ------------------------------------------------------------------------ INSERT /*+ append */ INTO EMP2XT ( EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO ) SELECT "EMPNO", "ENAME", "JOB", "MGR", "HIREDATE", "SAL", "COMM", "DEPTNO" FROM "SYS_SQLLDR_X_EXT_EMP2XT"
statements to cleanup objects created by previous statements: ------------------------------------------------------------------------ DROP TABLE "SYS_SQLLDR_X_EXT_EMP2XT" DROP DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000
Run began on Sat Jan 26 20:16:38 2013 Run ended on Sat Jan 26 20:16:38 2013
Elapsed time was: 00:00:00.26 CPU time was: 00:00:00.12
CREATE TABLE emp2xt_xt ( "EMPNO" NUMBER(4), "ENAME" VARCHAR2(10), "JOB" VARCHAR2(9), "MGR" NUMBER(4), "HIREDATE" DATE, "SAL" NUMBER(7,2), "COMM" NUMBER(7,2), "DEPTNO" NUMBER(2) ) ORGANIZATION external ( TYPE oracle_loader DEFAULT DIRECTORY ext_dir ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE CHARACTERSET ZHS16GBK FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM MISSING FIELD VALUES ARE NULL REJECT ROWS WITH ALL NULL FIELDS ( "EMPNO" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "ENAME" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "JOB" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "MGR" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "HIREDATE" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' DATE_FORMAT DATE MASK "DD-MM-YY" NULLIF ("HIREDATE" = "NULL"), "SAL" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "COMM" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', "DEPTNO" CHAR(255) TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' ) ) location ( 'emp2xt.dat' ) )REJECT LIMIT UNLIMITED;
验证外部表数据 SQL> select * from emp2xt_xt;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 17-DEC-80 800 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 10 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7839 KING PRESIDENT 17-NOV-81 5000 10 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7900 JAMES CLERK 7698 03-DEC-81 950 30 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
3.从外部表到oracle表加载数据
1.创建内部表或者加载数据 create table employee as select * from ext_emply where 1=2;
2.insert into SQL> insert into employee select * from ext_emply where EMPLOYEE_ID <=400;
5 rows created. 4. select * from DBA_EXTERNAL_TABLES ; select * from DBA_EXTERNAL_LOCATIONS ;
SQL> select OWNER,TABLE_NAME,TYPE_OWNER,TYPE_NAME,DEFAULT_DIRECTORY_NAME from DBA_EXTERNAL_TABLES;
OWNER TABLE_NAME TYP TYPE_NAME DEFAULT_DIRECTORY_NAME ------------------------------ ------------------------------ --- ------------------------------ ---------------- TEST EMP_XT SYS ORACLE_DATAPUMP EXT_DIR
SQL> col LOCATION format a50 SQL> select * from DBA_EXTERNAL_LOCATIONS
OWNER TABLE_NAME LOCATION DIR DIRECTORY_NAME ---------- ------------------------------ -------------------------------------------------- --- ------------------------------ TEST EMP_XT emp_xt.dmp SYS EXT_DIR