36般手艺,样样俱全--plsql导入excel批量数据(数据量较大)

https://blog.csdn.net/qq_37916752/article/details/108300129

plsql数据导入

1.当数据量较小的时候,将excel的字段整理成和数据库表字段的顺序一致,然后复制excel中的数据,表名: table
执行:

select * from table for update

在这里插入图片描述
选中第一列,右键复制即可。
2.数据量较大时,利用plsql的***TextImport***进行数据的导入

    1. 将exce文件另存为文本文件
      在这里插入图片描述
      2.打开plsql的TextImport
      在这里插入图片描述
      选择生成的文本文件
      3.选择要导入的表,以及相应字段
      在这里插入图片描述
      最后点左下角的import就可以了~。

https://blog.csdn.net/weixin_44250329/article/details/107228255

一:打开plsql,连接数据库,准备好excel(大量数据)文件

这里的采用随机生成的uuid

格式:600d65bc-948a-1260-2217-fd8dfeebb1cd

=CONCATENATE(IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),"-",IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),"-",IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),"-",IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),"-",IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)))

格式:600d65bc948a12602217fd8dfeebb1cd

=CONCATENATE(IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)),IF(RANDBETWEEN(1,2)=1,CHAR(RANDBETWEEN(0,9)+48),CHAR(RANDBETWEEN(0,5)+97)))

 

二、导入excel文件(这里需要注意excel中的字段类型要与导入目标数据库表中的字段一 一对应,这里可以提前写好)

选中表,点击切换上面的Data to Oracle  

 general下 点击table,下拉栏,选中对应的数据库,如何excel表中的字段名一致,plsql会自动匹配。选完之后需要点击一下fields中任意一个字段才能点击下方的import按钮,import之前,检查一下第三步的字段名、字段类型是否一致。

 完成之后记得查询一下数据,如何对插入的不满意,直接delete 再来一次就好。

附加:

在oracle sql中自带select sys_guid() from dual;  guid方法。

百度搜:拾取坐标系统。

在数据库中使用sql语句,循环添加数据,亲测 有效:

  1. BEGIN
  2. for i in 1 .. 138 //循环138次
  3. loop
  4. insert into 表名 (表字段) VALUES (sys_guid());
  5. end loop;
  6. commit;
  7. end;

 

 

 

 https://blog.csdn.net/striving_77/article/details/53995499

一、想通过plsql在表中直接添加一条记录点击小锁的时候,出现如下错误:These query results are not updateable.Include the ROWID to get updateable results. 如截图:

解决方法:

1、查询语句后面加for update:select *  from  CBS_CATV_SMARTCARD where usercode ='9002733' for update ;

2、加rowid字段:select CBS_CATV_SMARTCARD.*,rowid from  CBS_CATV_SMARTCARD where usercode ='9002733' ;

二、添加好后点击‘+’按钮,插入记录,然后点击页面中的勾记入改变,最后点击commit提交按钮。

下面是截得别人的笔记,还不错,从来没用过回滚,以前都没关注过,好用的按钮啊

posted @ 2021-03-11 18:51  CharyGao  阅读(1980)  评论(0编辑  收藏  举报