Oracle11g在Windows和Linux下imp导入表,exp导出表,sqluldr2导出表,sqlldr导入表

Oracle11g在Windows和Linux下imp导入表,exp导出表,sqluldr2导出表,sqlldr导入表

Windows(Win10)

打开cmd

首先输入sqlplus,依次输入用户名、口令

C:\Users\hasee>sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 3月 13 16:55:46 2019

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

请输入用户名:  scott
输入口令:

连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

连接数据库管理员

[oracle@CentOS7One ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期一 3月 18 14:28:40 2019

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

已连接到空闲例程。

1.exp导出表

退出oracle,将scott用户下orcl数据库的buy_cnt_c1表导出到e:/opt/oracle_output/daochu.dmp

C:\Users\hasee>exp scott/tiger@orcl file=e:\opt\\oracle_output\daochu.dmp tables=(buy_cnt_c1)

Export: Release 11.2.0.1.0 - Production on 星期三 3月 13 16:58:30 2019

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集

即将导出指定的表通过常规路径...
. . 正在导出表                      BUY_CNT_C1导出了        8293 行
成功终止导出, 没有出现警告。

8293条数据 22ms

8492033条数据18s65ms

2.imp导入表

导入前要将原来的表删除

drop table buy_cnt_c1;

退出oracle,将e:/opt/oracle_output/daochu.dmp导入到scott用户下orcl数据库

C:\Users\hasee>imp scott/tiger@orcl file=e:\opt\\oracle_output\daochu.dmp

Import: Release 11.2.0.1.0 - Production on 星期三 3月 13 17:03:29 2019

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

经由常规路径由 EXPORT:V11.02.00 创建的导出文件
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
. 正在将 SCOTT 的对象导入到 SCOTT
. 正在将 SCOTT 的对象导入到 SCOTT
. . 正在导入表                    "BUY_CNT_C1"导入了        8293 行
成功终止导入, 没有出现警告。

8293条数据  18ms

8492033条数据 1m19s8ms

 3.sqluldr2导出表

E:\bigdata\sqluldr2_win_jb51>sqluldr264 scott/tiger@127.0.0.1/orcl query="select * from buy_cnt_c1" head=yes file=e:\opt\oracle_output\tmp001.txt
           0 rows exported at 2019-03-13 17:40:46, size 0 MB.
        8293 rows exported at 2019-03-13 17:40:46, size 0 MB.
         output file e:\opt\oracle_output\tmp001.txt closed at 8293 rows, size 0 MB.

8293条数据  23ms

8492033条数据17s55ms

4.sqlldr导入数据

首先创建表

DROP TABLE "SCOTT"."BUY_CNT_C1";
CREATE TABLE "SCOTT"."BUY_CNT_C1" (
"T_INDEX" NUMBER(19) NULL ,
"INNET_TIME" NUMBER(19) NULL ,
"UP_DATA_AMOUNT_TOTAL" FLOAT(126) NULL ,
"DOWN_DATA_AMOUNT_TOTAL" FLOAT(126) NULL ,
"PAY_CNT" NUMBER(19) NULL ,
"BUY_CNT" NUMBER(19) NULL ,
"MONTH_FEE" FLOAT(126) NULL ,
"CALL_DURATION" NUMBER(19) NULL ,
"AGE_RANGE_ID" FLOAT(126) NULL ,
"DAY_ACT_NUM_MEAN" FLOAT(126) NULL 
)
LOGGING
NOCOMPRESS
NOCACHE

;

编写ctl文件

tmp_002.ctl

load data

infile *

into table BUY_CNT_TEST     

(

"T_INDEX" char terminated  by   ',',
"INNET_TIME" char terminated   by   ',',
"UP_DATA_AMOUNT_TOTAL" char terminated   by   ',',
"DOWN_DATA_AMOUNT_TOTAL" char terminated   by   ',',
"PAY_CNT" char terminated   by   ',',
"BUY_CNT"  char terminated   by   ',',
"MONTH_FEE" char terminated   by   ',',
"CALL_DURATION"  char terminated   by   ',',
"AGE_RANGE_ID" char terminated   by   ',',
"DAY_ACT_NUM_MEAN" char terminated   by   ','
)

cmd输入

E:\bigdata\sqluldr2_win_jb51>sqlldr userid=scott/tiger control=e:/opt/oracle_ctl/tmp002.ctl log=e:/opt/oracle_ctl/tmp001.log data=e:/opt/oracle_ctl/tmp001.csv rows=64

SQL*Loader: Release 11.2.0.1.0 - Production on 星期四 3月 14 10:50:46 2019

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

达到提交点 - 逻辑记录计数 64
达到提交点 - 逻辑记录计数 128
达到提交点 - 逻辑记录计数 192
达到提交点 - 逻辑记录计数 256

...
达到提交点 - 逻辑记录计数 8192 达到提交点 - 逻辑记录计数 8256 达到提交点 - 逻辑记录计数 8294

8294条数据 28ms

8492033条数据 2m6s12ms

Linux(CentOS7)

1.exp导出表

[oracle@CentOS7One ~]$ exp scott/tiger file=output/daochu.dmp tables='(buy_cnt_c1)' log=output/log/daochudmp.log

Export: Release 11.2.0.1.0 - Production on 星期三 3月 20 09:12:08 2019

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已导出 AL32UTF8 字符集和 AL16UTF16 NCHAR 字符集
服务器使用 ZHS16GBK 字符集 (可能的字符集转换)

即将导出指定的表通过常规路径...
. . 正在导出表                      BUY_CNT_C1导出了     8492032 行
成功终止导出, 没有出现警告。

8293条数据 2s

8492033条数据60s

2.imp导入表

导入前要将原来的表删除

drop table buy_cnt_c1;
[oracle@CentOS7One ~]$ imp scott/tiger@orcl11g file=input/daoru.cmp 

Import: Release 11.2.0.1.0 - Production on 星期三 3月 20 10:42:51 2019

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

经由常规路径由 EXPORT:V11.02.00 创建的导出文件
已经完成 AL32UTF8 字符集和 AL16UTF16 NCHAR 字符集中的导入
导入服务器使用 ZHS16GBK 字符集 (可能的字符集转换)
. 正在将 SCOTT 的对象导入到 SCOTT
. 正在将 SCOTT 的对象导入到 SCOTT
. . 正在导入表                    "BUY_CNT_C1"导入了     8492032 行
成功终止导入, 没有出现警告。

8293条数据 48ms

8492032条数据61s

3.sqluldr2导出数据

sqluldr2_linux64_10204.bin user=scott/tiger@orcl11g query="select * from buy_cnt_c1" head=yes file=output/tmp002.csv log=output/log/tmp002.log

8293条数据 小于1s

8492032条数据 5min17s

4.sqlldr导入数据

ctl文件同上,先创建表

[oracle@CentOS7One ~]$ sqlldr userid=scott/tiger control=input/tmp002.ctl log=input/log/tmp002.log data=input/tmp001.csv rows=64

SQL*Loader: Release 11.2.0.1.0 - Production on 星期二 3月 19 16:46:56 2019

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

达到提交点 - 逻辑记录计数 64
达到提交点 - 逻辑记录计数 128
达到提交点 - 逻辑记录计数 192
达到提交点 - 逻辑记录计数 256
达到提交点 - 逻辑记录计数 320
...
达到提交点 - 逻辑记录计数 8192
达到提交点 - 逻辑记录计数 8256
达到提交点 - 逻辑记录计数 8294

8294条数据  47ms

8492033数据  5m27s26ms

 

测试

编写测试脚本,统计脚本命令执行时间

Windows脚本如下

@echo off
set /a startMS=%time:~9,2%
set /a startS=%time:~6,2%
set /a startM=%time:~3,2%
echo %time%

::写你的命令

set /a endMS=%time:~9,2%
set /a endS=%time:~6,2%
set /a endM=%time:~3,2%
echo %time%
set /a diffMS_=%endMS%-%startMS%
set /a diffS_=%endS%-%startS%
set /a diffM_=%endM%-%startM%
echo cost:%diffM_% %diffS_% %diffMS_%
pause

 

Linux脚本如下

start_time=`date --date='0 days ago' "+%Y-%m-%d %H:%M:%S"`
#this is your shell script

#写你的命令

############## finish_time=`date --date='0 days ago' "+%Y-%m-%d %H:%M:%S"` duration=$(($(($(date +%s -d "$finish_time")-$(date +%s -d "$start_time"))))) echo "this shell script execution duration: $duration"

 

CentOS7部署在虚拟机上,所以配置较Windows差很多

8294条数据(小数据量)

 8492033条数据(大数据量)

总结

exp导出和imp导入的效率要大于sqluldr2和sqlldr;

小数据量体现不出来exp和imp的优势,效率和sqluldr2和sqlldr差不多;

大数据量exp和imp明显优于sqluldr2和sqlldr;

硬件配置高会提高导入导出效率;

不同数据库迁移建议使用sqluldr2和sqlldr,支持csv,txt等数据格式的导入导出;

 

posted @ 2019-03-13 17:06 Rest探路者 阅读( ...) 评论( ...) 编辑 收藏
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值