将文本文件导入Oracle中需要用sqlloader的方式。
1、在数据库中创建相应的表。
如,文本文件内容为:
create table test(id int,name varchar2(10),sex varchar2(10));2、在电脑中某路径下编写ctrl文件,以c盘data目录为例,添加如下文本。如,被导入的文件名为load.txt
load data infile 'load.txt' --被导入文件名 replace into table test (id char terminated by ',', name char terminated by ',', sex char terminated by whitespace)编写后,将文件保存成load.ctrl
3、然后打开命令提示符,并进入到文本文件和ctrl文件所在目录。
4、输入以下语句,并执行。
sqlldr userid=用户名/密码@数据库实例名 control=load.ctl log=load.log
5、导入后,test表中数据如下: