plsql导入excel

发布于:2024-06-11 ⋅ 阅读:(143) ⋅ 点赞:(0)

1.建临时表:(字段对应excel表头)

create table temp_old_table(

       atomname nvarchar2(4000),   --原子名称

       koujingname nvarchar2(4000)  --供应商名称

       );

2.Plsql–>工具(tool)–>ODBC导入器(ODBC Importer)

用户/系统 DSN选择第二项Excel Files
问题
用户/系统 DSN没有下拉选择项

Download Microsoft Access 2016 数据库引擎可再发行程序包
选择安装64位的office

知乎这篇文章告诉如果之前安装32位处理方式,我没遇到,没亲测

下载完,打开 ODBC 数据源管理器
在这里插入图片描述

在“开始”页上,键入“ODBC 数据源”。我直接选择ODBC 数据源(64位)
在这里插入图片描述
3.选择连接(Connect)在弹出框里选择你要导入的Excel文件
在这里插入图片描述

4.预览你的数据,之后单击 到ORACLE的数据(Data to Oracle)
在这里插入图片描述

5.操作步骤

    5.1选择表名和数据库登录名

    5.2选择excel表头对应的临时表字段

    5.3点击导入按钮

在这里插入图片描述

这里点击导入,右下角就一直显示导入记录(点击口径却没把Field填,只写了FeildType选择string,白白高兴,还得重新导入)
在这里插入图片描述
成功
在这里插入图片描述

总结:
导入一次失败经验
在这里插入图片描述

业务需要(实战)

一个表里temp_old_table有两个在字段原子名称和口径,近两万条数据,
另一个只有原子名称temp_new_table也是两个字段原子名称和口径,口径没值,要输入口径
要根据temp_old_table的原子名称把对应的口径输入值到temp_new_table里面

导入后的temp_old_table表
在这里插入图片描述

导入后的temp_new_table表
在这里插入图片描述

因为temp_old_table有重复的atomname,所以执行update的时候要distinct
在这里插入图片描述

执行sql语句赋值

update temp_new_table o set o.koujingname=(select distinct temp.koujingname from temp_old_table temp where o.atomname=temp.atomname)

where exists

(select 1 from temp_old_table t where o.atomname=t.atomname)

temp_new_table 在导入的时候有95条数据,还是95条并已经赋值成功
在这里插入图片描述


网站公告

今日签到

点亮在社区的每一天
去签到