Oracle SQL*Loader 的使用简介
前面一文简单介绍了 sqluldr2 的安装与使用,sqluldr2 的诞生主要是用于将大批量的 Oracle 数据快速导出成 CSV/Text 文本格式,方便导入到其他数据库中,如今国产化进行的如火如荼,这个工具也是在国产数据库迁移中使用比较广泛的工具,值得大家去学习与使用,今天要说的是 Oracle 数据库自带的数据导入工具 SQL*Loader(sqlldr),只要你安装了 Oracle 数据库,那么这个工具就存在于 ORACLE_HOME/bin 目录下,它的功能是将从其他数据库中导出的 DAT/CSV/Text 文件加载到 Oracle 数据库中。
SQL*Loader 原理
[oracle@oracle dir1]$ vi /home/oracle/dir1/emp1.ctl load data
infile '/home/oracle/dir1/emp1.dat' insert
into table emp1
fields terminated by ',' (empno,ename,sal,comm,deptno)
在 scott 下建立 emp1 表结构(内部表)
SCOTT@PROD>create table emp1 as select * from emp1_ext where 1=2;
ORACLE_LOADER 引擎导入(normal 方式)
[oracle@oracle ~]$cd /home/oracle/dir1
[oracle@oracle dir1]$ ll
[oracle@oracle dir1]$ sqlldr
[oracle@oracle dir1]$ sqlldr scott/tiger control=emp1.ctl log=emp1.log data=emp1.dat
验证结果
SCOTT@PROD>select * from emp1;
数据源和控制文件合并在.ctl 里描述
[oracle@oracle dir1]$ vi emp2.ctl
load data
infile *
append
into table emp1
fields terminated by ',' optionally enclosed by '"' (empno,ename,sal,comm,deptno)
begindata
8888,Jieke,1000,,"10"
9999,ORACLE,8000,100,20
[oracle@oracle dir1]$ sqlldr scott/tiger control=emp2.ctl log=emp2.log
官方文档链接:
https://docs.oracle.com/en/database/oracle/oracle-database/19/sutil/oracle-sql-loader-concepts.html#GUID-F99250F9-F720-45EE-8159-9B8A8E5A77D6
全文完,希望可以帮到正在阅读的你,如果觉得此文对你有帮助,可以分享给你身边的朋友,同事,你关心谁就分享给谁,一起学习共同进步~~~
欢迎关注我的公众号【JiekeXu DBA之路】,第一时间一起学习新知识!
————————————————————————————
公众号:JiekeXu DBA之路
CSDN :https://blog.csdn.net/JiekeXu
墨天轮:https://www.modb.pro/u/4347
腾讯云:https://cloud.tencent.com/developer/user/5645107
————————————————————————————