SQLLoader2(导入EXCEL或csv格式的文件)

一、EXCEL文件导入:
1、首先将EXCEL文件另存为CSV格式文件--->用UltraEdit工具打开时可看到字段之间以逗号分隔。

  ,EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
1,7369,SMITH,CLERK,7902,1980/12/17,800,,20
2,7499,ALLEN,SALESMAN,7698,1981/2/20,1600,300,30
3,7521,WARD,SALESMAN,7698,1981/2/22,1250,500,30
4,7566,JONES,MANAGER,7839,1981/4/2,2975,,20
5,7654,MARTIN,SALESMAN,7698,1981/9/28,1250,1400,30
6,7698,BLAKE,MANAGER,7839,1981/5/1,2850,,30
7,7782,CLARK,MANAGER,7839,1981/6/9,2450,,10
8,7788,SCOTT,ANALYST,7566,1987/4/19,3000,,20
9,7839,KING,PRESIDENT,,1981/11/17,5000,,10
10,7844,TURNER,SALESMAN,7698,1981/9/8,1500,0,30
11,7876,ADAMS,CLERK,7788,1987/5/23,1100,,20
12,7900,JAMES,CLERK,7698,1981/12/3,950,,30
13,7902,FORD,ANALYST,7566,1981/12/3,3000,,20
14,7934,MILLER,CLERK,7782,1982/1/23,1300,,10

2、执行导入
--编写控制文件:testSqlLdr2.ctl

OPTIONS(SKIP=1) --跳过第一行
LOAD DATA
INFILE ‘D:\oracletest\testSqlLdr2.csv‘
APPEND
INTO TABLE EMP2
FIELDS TERMINATED BY ‘,‘
(
virtual_column FILLER, --这是一个虚拟字段,用来跳过由PL/SQL Developer生成的第一列序号
EMPNO,ENAME,JOB,MGR,HIREDATE date ‘YYYY/MM/DD‘,SAL,COMM,DEPTNO)

--执行命令

D:\oracletest>sqlldr scott/tiger@orcl control=testSqlLdr2.ctl

SQL*Loader: Release 11.2.0.1.0 - Production on 星期日 11月 30 15:35:40 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

达到提交点 - 逻辑记录计数 14

--验证结果
--已导入成功

SQL> select * from emp2;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- -------------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-12月-80 800 20
7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30
7521 WARD SALESMAN 7698 22-2月 -81 1250 500 30
7566 JONES MANAGER 7839 02-4月 -81 2975 20
7654 MARTIN SALESMAN 7698 28-9月 -81 1250 1400 30
7698 BLAKE MANAGER 7839 01-5月 -81 2850 30
7782 CLARK MANAGER 7839 09-6月 -81 2450 10
7788 SCOTT ANALYST 7566 19-4月 -87 3000 20
7839 KING PRESIDENT 17-11月-81 5000 10
7844 TURNER SALESMAN 7698 08-9月 -81 1500 0 30
7876 ADAMS CLERK 7788 23-5月 -87 1100 20
7900 JAMES CLERK 7698 03-12月-81 950 30
7902 FORD ANALYST 7566 03-12月-81 3000 20
7934 MILLER CLERK 7782 23-1月 -82 1300 10

已选择14行。

二、CSV文件的导入
1、这种文件一般是从PLSQL中导出的查询结果,内容格式如下:

" ","EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO"
"1","7369","SMITH","CLERK","7902","1980/12/17","800.00","","20"
"2","7499","ALLEN","SALESMAN","7698","1981/2/20","1600.00","300.00","30"
"3","7521","WARD","SALESMAN","7698","1981/2/22","1250.00","500.00","30"
"4","7566","JONES","MANAGER","7839","1981/4/2","2975.00","","20"
"5","7654","MARTIN","SALESMAN","7698","1981/9/28","1250.00","1400.00","30"
"6","7698","BLAKE","MANAGER","7839","1981/5/1","2850.00","","30"
"7","7782","CLARK","MANAGER","7839","1981/6/9","2450.00","","10"
"8","7788","SCOTT","ANALYST","7566","1987/4/19","3000.00","","20"
"9","7839","KING","PRESIDENT","","1981/11/17","5000.00","","10"
"10","7844","TURNER","SALESMAN","7698","1981/9/8","1500.00","0.00","30"
"11","7876","ADAMS","CLERK","7788","1987/5/23","1100.00","","20"
"12","7900","JAMES","CLERK","7698","1981/12/3","950.00","","30"
"13","7902","FORD","ANALYST","7566","1981/12/3","3000.00","","20"
"14","7934","MILLER","CLERK","7782","1982/1/23","1300.00","","10"

2、执行导入
--编写控制文件:testSqlLdr3.ctl

OPTIONS(SKIP=1) --跳过第一行
LOAD DATA
INFILE ‘D:\oracletest\222.csv‘
REPLACE
INTO TABLE EMP2
FIELDS TERMINATED BY ‘,‘
OPTIONALLY ENCLOSED BY ‘"‘ -- 数据中每个字段用 ‘"‘ 框起
(
virtual_column FILLER, --这是一个虚拟字段,用来跳过由PL/SQL Developer生成的第一列序号
EMPNO,ENAME,JOB,MGR,HIREDATE date ‘YYYY/MM/DD‘,SAL,COMM,DEPTNO)

--执行命令,导入成功

D:\oracletest>sqlldr scott/tiger@orcl control=testSqlLdr3.ctl

SQL*Loader: Release 11.2.0.1.0 - Production on 星期日 11月 30 15:43:26 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

达到提交点 - 逻辑记录计数 14
时间: 2024-11-08 13:49:54

SQLLoader2(导入EXCEL或csv格式的文件)的相关文章

Python,使用pandas保存数据为csv格式的文件

使用pandas对数据进行保存时,可以有两种形式进行保存 一.对于数据量不是很大的文件,可以放到列表中,进行一次性存储. 二.对于大量的数据,可以考虑一边生成,一边存储,可以避免开辟大量内存空间,去往列表中存储数据. 本人才疏学浅,只懂一些表面的东西,如有错误,望请指正! 下面通过代码进行说明 1 import pandas as pd 2 3 4 class SaveCsv: 5 6 def __init__(self): 7 self.clist = [[1,2,3], [4,5,6], [

将Excel另存为CSV格式文件

直接将Excel另存为CSV,速度很快: $FilePath_Public_ip_maps_infos="D:\My Documents\Work\IP映射表.xlsx" $Excel = New-Object -Com Excel.Application $Excel.visible = $False $Excel.displayalerts=$False $WorkBook = $Excel.Workbooks.Open($FilePath_Public_ip_maps_infos

图解-Excel的csv格式特殊字符处理方式尝试笔记(个人拙笔)

Excel格式如下.(截图来自,WPS Office) CSV是一种文本格式的Excel文档格式.不支持Excel的字体特效(比如加粗,颜色)等等的保存. 每一行数据用 "\n" 换行符分开,单行列之间用逗号","分开,(是英文输入法下的逗号哦.o(∩_∩)o ) 如果单行列中有逗号","字符,此行的此列将使用双引号包含数据.如果既有逗号,也有双引号字符.双引号字符 将会使用2个双引号字符替代.都说有图有真相,来.来.来.上图了咯 (Excel文

C#对.CSV格式的文件--逗号分隔值 的读写及上传ftp服务器操作方法总结

前言 公司最近开发需要将数据保存到.csv文件(逗号分隔值 )中然后上传到ftp服务器上,供我们系统还有客户系统调用,之前完全没有接触过这个,所以先来看看百度的解释:逗号分隔值(Comma-Separated Values,CSV,有时也称为字符分隔值,因为分隔字符也可以不是逗号),其文件以纯文本形式存储表格数据(数字和文本).纯文本意味着该文件是一个字符序列,不含必须像二进制数字那样被解读的数据.CSV文件由任意数目的记录组成,记录间以某种换行符分隔:每条记录由字段组成,字段间的分隔符是其它字

C#第三次作业:在c#中导入excel,并生成html文件

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OleDb; using System.IO; namespace readFile { pub

使用NPOI导入Excel注意日期格式和数字格式

//使用NPOI导入Excel public static DataTable importExcelToDataSetUsingNPOI(string FilePath, string fileName) { DataSet myDs = new DataSet(); DataTable dt = new DataTable("mytable"); myDs.Tables.Add(dt); DataRow myRow; myDs.Clear(); try { using (Strea

将.csv格式的文件导入oracle数据库中

第一种方法 1.选择工具---文本导入器 2.选择 到oracle的数据选择所有者和表. 3.选择打开文件,选择要导入的文本 4.在field中配置表的对应关系,filed1对应的是.csv中的第一列,配置对应数据的那一列,注意类型,不然导入数据会报错.之后点导入,完成. 第二种方法 1.创建控制文件 如,在E:\创建 test.ctl文件,文件内容为 load data ---控制文件标志 infile'e:/asd.csv'---要输入的文件名及路径 into tablejyzxsj_rdl

将CSV格式的文件导入到数据中

--创建表 create table t1( id number primary key, name varchar2(10), score number, subject varchar(10) ) --创建控制文件 t1.ctl,以文本的形式保存为ctl 格式的,放在所在目录下 load data infile 'D:\test\student.csv' insert into table t1 fields terminated by ','(id,name,score,subject)

Excel和CSV格式文件的不同之处

来源:https://blog.csdn.net/weixin_39198406/article/details/78705016 1.个人理解:为何选择使用csv来存储接口测试用例相关字段数据,而不选择excel,主要原因是 "CSV是安全的,可以清楚地区分数值和文本.CSV不处理数据并按原样存储. 而由于数值和文本之间没有明确的区别或区分,Excel可以使用自动格式化功能搞乱您的邮政编码和信用卡号码,所以会造成接口用例相关字段参数值错误. " 2.后续,是直接采用yaml配置文件来