1.生成百万级的sql,保存SQL文件为getobject.sql select a.owner||',"'||a.object_name||'",'||a.object_id||','||to_char(a.created ,'yyyy-mm-dd hh24:mi:ss')||','||a.status from dba_objects a,(select rownum from dual connect by rownum <= 20);
2.sql数据转换成数据文件,保存脚本为call.sql
set echo off set term off set trimout on set trimspool on set pagesize 0 set feedback off set heading off spool c:\getobject.csv @c:\getobject.sql set spool off set heading on set feedback on set trimspool off set trimout off set term on set echo on
注释: set colsep' '; //-域输出分隔符 set echo off; //显示start启动的脚本中的每个sql命令,缺省为on set echo on //设置运行命令是是否显示语句 set feedback on; //设置显示“已选择XX行” set feedback off; //回显本次sql命令处理的记录条数,缺省为on set heading off; //输出域标题,缺省为on set pagesize 0; //输出每页行数,缺省为24,为了避免分页,可设定为0。 set linesize 80; //输出一行字符个数,缺省为80 set numwidth 12; //输出number类型域长度,缺省为10 set termout off; //显示脚本中的命令的执行结果,缺省为on set trimout on; //去除标准输出每行的拖尾空格,缺省为off set trimspool on; //去除重定向(spool)输出每行的拖尾空格,缺省为off set serveroutput on; //设置允许显示输出类似dbms_output set timing on; //设置显示“已用时间:XXXX” set autotrace on-; //设置允许对执行的sql进行分析 set verify off //可以关闭和打开提示确认信息old 1和new 1的显示.
3.运行call.sql 生成数据文件
sqlplus hxadmin/secret as sysdba; @c:\call.sql
4.初始化环境,创建导入表OBjects
create table OBJECTS ( OWNER VARCHAR2(50), OBJECT_NAME VARCHAR2(50), OBJECT_ID NUMBER, STATUS VARCHAR2(10), CREATED DATE )
5.生成导入控制文件,保存控制文件为ldr_object.ctl
LOAD DATA INFILE getobject.csv TRUNCATE INTO TABLE OBJECTS FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS (OWNER, OBJECT_NAME, OBJECT_ID, CREATED date 'yyyy-mm-dd hh24:mi:ss', STATUS)
6.执行sqlldr命令
C:> sqlldr hxadmin/secret control= ldr_object.ctl direct = true
7.查看ldr_object.log日志文件
这个例子 是我自己做的 一个100W 行的数据插入也只要10几秒。希望你能用到。
薄荷心凉
2024-11-07 01:25:08
insert into 销售表(字段1,字段2,字段3,字段4) values ('0001','电视','500','1000') insert into 销售表(字段1,字段2,字段3,字段4) values ('0002','电脑','4000','2000')
依次类推,是这意思么?
为你╰我宁愿放下
2024-11-07 03:38:13
insert 表名 (列名,列名)
select 值1,值2 union select 值1,值2 union select 值1,值2
爱在千年梦
2024-11-07 05:26:17
insert into tb select '0001', '电视', 500, 1000 union all select '0002', '电脑', 4000, 2000 union all select ..............