首页 > 代码库 > SQLLoader7(只导入数据文件的其中几行记录)

SQLLoader7(只导入数据文件的其中几行记录)

数据文件:

D:\oracletest\test1.txt
1 SMITH CLERK 7902 1980-12-17 800 0 202 ALLEN SALESMAN 7698 1981-02-20 1600 300 303 WARD SALESMAN 7698 1981-02-22 1250 500 304 JONES MANAGER 7839 1981-04-02 2975 0 205 MARTIN SALESMAN 7698 1981-09-28 1250 1400 306 BLAKE MANAGER 7839 1981-05-01 2850 0 307 CLARK MANAGER 7839 1981-06-09 2450 0 108 SCOTT ANALYST 7566 1987-04-19 3000 0 209 KING PRESIDENT 1111 1981-11-17 5000 0 1010 TURNER SALESMAN 7698 1981-09-08 1500 0 3011 ADAMS CLERK 7788 1987-05-23 1100 0 2012 JAMES CLERK 7698 1981-12-03 950 0 3013 FORD ANALYST 7566 1981-12-03 3000 0 2014 MILLER CLERK 7782 1982-01-23 1300 0 10

控制文件:

D:\oracletest\testSqlLdr3.ctl
LOAD DATAINFILE D:\oracletest\test1.txtBADFILE D:\oracletest\testSqlLdr3.badDISCARDFILE D:\oracletest\testSqlLdr3.dscREPLACEINTO TABLE emp2FIELDS TERMINATED BY WHITESPACE(EMPNO,ENAME,JOB,MGR,HIREDATE DATE "YYYY-MM-DD",SAL,COMM,DEPTNO)

导入方式:
以下测试的数据导入,使用的控制文件都是同一个。
1、从第5行开始导入 skip=4,使用skip参数跳过前边4行。
执行命令时加上参数:skip=N,即导入第N+1行后的所有文件。

D:\oracletest>sqlldr scott/tiger@orcl control=D:\oracletest\testSqlLdr3.ctl skip=4SQL*Loader: Release 11.2.0.1.0 - Production on 星期一 12月 1 00:08:03 2014Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.达到提交点 - 逻辑记录计数 9达到提交点 - 逻辑记录计数 10

查看导入结果:

SQL> select * from emp2;EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO---------- ---------- --------- ---------- ---------- ---------- ---------- ----------5 MARTIN SALESMAN 7698 1981-09-28 1250 1400 306 BLAKE MANAGER 7839 1981-05-01 2850 0 307 CLARK MANAGER 7839 1981-06-09 2450 0 108 SCOTT ANALYST 7566 1987-04-19 3000 0 209 KING PRESIDENT 1111 1981-11-17 5000 0 1010 TURNER SALESMAN 7698 1981-09-08 1500 0 3011 ADAMS CLERK 7788 1987-05-23 1100 0 2012 JAMES CLERK 7698 1981-12-03 950 0 3013 FORD ANALYST 7566 1981-12-03 3000 0 2014 MILLER CLERK 7782 1982-01-23 1300 0 10已选择10行。

2、只导入其中的第3行至第10行记录
即:SKIP=2 LOAD=10---LOAD指定要导入的数据行数。

D:\oracletest>sqlldr scott/tiger@orcl control=D:\oracletest\testSqlLdr3.ctl skip=4 load=10SQL*Loader: Release 11.2.0.1.0 - Production on 星期一 12月 1 00:09:46 2014Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.达到提交点 - 逻辑记录计数 9达到提交点 - 逻辑记录计数 10

查看导入结果:

SQL> select * from emp2;EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO---------- ---------- --------- ---------- ---------- ---------- ---------- ----------5 MARTIN SALESMAN 7698 1981-09-28 1250 1400 306 BLAKE MANAGER 7839 1981-05-01 2850 0 307 CLARK MANAGER 7839 1981-06-09 2450 0 108 SCOTT ANALYST 7566 1987-04-19 3000 0 209 KING PRESIDENT 1111 1981-11-17 5000 0 1010 TURNER SALESMAN 7698 1981-09-08 1500 0 3011 ADAMS CLERK 7788 1987-05-23 1100 0 2012 JAMES CLERK 7698 1981-12-03 950 0 3013 FORD ANALYST 7566 1981-12-03 3000 0 2014 MILLER CLERK 7782 1982-01-23 1300 0 10已选择10行。

3、前3行和最后2行不导入
相当于只导入从第4行至总行数减2行之间的数据,skip=2,load=9

D:\oracletest>sqlldr scott/tiger@orcl control=D:\oracletest\testSqlLdr3.ctl skip=4 load=9SQL*Loader: Release 11.2.0.1.0 - Production on 星期一 12月 1 00:14:09 2014Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.达到提交点 - 逻辑记录计数 9

查看导入结果:

SQL> select * from emp2;EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO---------- ---------- --------- ---------- ---------- ---------- ---------- ----------5 MARTIN SALESMAN 7698 1981-09-28 1250 1400 306 BLAKE MANAGER 7839 1981-05-01 2850 0 307 CLARK MANAGER 7839 1981-06-09 2450 0 108 SCOTT ANALYST 7566 1987-04-19 3000 0 209 KING PRESIDENT 1111 1981-11-17 5000 0 1010 TURNER SALESMAN 7698 1981-09-08 1500 0 3011 ADAMS CLERK 7788 1987-05-23 1100 0 2012 JAMES CLERK 7698 1981-12-03 950 0 3013 FORD ANALYST 7566 1981-12-03 3000 0 20已选择9行。

 

SQLLoader7(只导入数据文件的其中几行记录)