Oracle utl_file读取csv文件到数据库
来源:互联网 发布:数据库原理课程设计 编辑:程序博客网 时间:2024/05/18 02:39
drop table test purge;
create table test
(
url varchar2(200),
res_time varchar2(10)
);
create or replace procedure loadfiledata(p_path varchar2,
p_filename varchar2) as
v_filehandle utl_file.file_type;
v_text varchar2(100);
v_url test.url%type;
v_res_time test.res_time%type;
v_firstlocation number;
begin
if (p_path is null or p_filename is null) then
goto to_end;
end if;
v_filehandle := utl_file.fopen(p_path, p_filename, 'r');
loop
begin
utl_file.get_line(v_filehandle, v_text);
exception
when no_data_found then
exit;
end;
v_firstlocation := instr(v_text, ',', 1, 1);
v_url := substr(v_text, 1, v_firstlocation - 1);
v_res_time := substr(v_text,v_firstlocation + 1);
insert into test values (v_url, v_res_time);
null;
end loadfiledata;
CREATE DIRECTORY utl_dir AS 'D:\'; --必须是以目录的形式
call loadfiledata('UTL_DIR','test.csv');
select * from test;
test.csv
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.013"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.013"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.013"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.016"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.016"
"web/tt/workbench/component/underscore/module.underscore.js?v=","0.016"
"web/tt/workbench/component/underscore/module.underscore.js?v=","0.016"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.016"
create table test
(
url varchar2(200),
res_time varchar2(10)
);
create or replace procedure loadfiledata(p_path varchar2,
p_filename varchar2) as
v_filehandle utl_file.file_type;
v_text varchar2(100);
v_url test.url%type;
v_res_time test.res_time%type;
v_firstlocation number;
begin
if (p_path is null or p_filename is null) then
goto to_end;
end if;
v_filehandle := utl_file.fopen(p_path, p_filename, 'r');
loop
begin
utl_file.get_line(v_filehandle, v_text);
exception
when no_data_found then
exit;
end;
v_firstlocation := instr(v_text, ',', 1, 1);
v_url := substr(v_text, 1, v_firstlocation - 1);
v_res_time := substr(v_text,v_firstlocation + 1);
insert into test values (v_url, v_res_time);
end loop;
commit;
null;
end loadfiledata;
CREATE DIRECTORY utl_dir AS 'D:\'; --必须是以目录的形式
call loadfiledata('UTL_DIR','test.csv');
select * from test;
test.csv
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.013"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.013"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.013"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.016"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.016"
"web/tt/workbench/component/underscore/module.underscore.js?v=","0.016"
"web/tt/workbench/component/underscore/module.underscore.js?v=","0.016"
"web/tt/sys/dwr/interface/ChooseAction.js?v=","0.016"
0 0
- Oracle utl_file读取csv文件到数据库
- 读取csv文件到数据库
- Oracle存储过程读取文件例子--UTL_FILE
- .csv文件导入到oracle数据库
- PHP读取CSV文件内容 并且插入到数据库中
- Java读取csv文件并将内容插入到数据库
- Android读取csv文件并写到数据库中
- Java读取csv文件并将内容插入到数据库
- 读取CSV文件到DataTable
- 读取CSV文件到DataTable
- 读取csv文件到datatable
- 用oracle utl_file包读取数据写入文件
- oracle UTL_FILE文件操作
- csv文件中的数据导入到oracle数据库中的方法
- 通过java导入csv文件到oracle(mysql)数据库
- 使用utl_file将oracle数据库中数据写入excel文件
- 使用utl_file将oracle数据库中数据写入excel文件
- csv文件导入oracle数据库
- js数组合并concat()和Array.prototype.push.apply()的性能分析
- 动画篇-碎片动画
- Java中多线程并发体系知识点汇总
- Linux memcached 环境配置
- win7 plsql里查询出来的中文信息,复制粘贴的时候出现乱码的解决方案
- Oracle utl_file读取csv文件到数据库
- DBA必须熟悉的、最有用的DBA视图。
- 逆向分析 Android 程序- 内存内存
- 初学多线程
- 产品经理爱好者的App评测之今日头条(一)
- 专题三 Problem B
- Android源码编译和APP编译步骤
- nginx常用命令
- Python爬虫:一些常用的爬虫技巧总结(IP,cookie,header,多线程)