mysql表导入到oracle

一、创建jack表,并导入一下数据

mysql> create table jack(id char(100),flwo char(100)) engine=myisam;
Query OK, 0 rows affected (0.08 sec)

mysql> load data infile '/u01/sqlload/taobao_9_11.txt' into table jack fields terminated by ',';
Query OK, 1469199 rows affected (20.09 sec)
Records: 1469199  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select * from jack limit 10;
+-------------+--------+
| id          | flwo   |
+-------------+--------+
| 13400017749 | 4594   |
| 13400087049 | 5044   |
| 13400826615 | 83029  |
| 13400977755 | 22505  |
| 13401509025 | 2671   |
| 13401584949 | 10435  |
| 13402065168 | 111061 |
| 13402077444 | 2525   |
| 13402133742 | 13204  |
| 13402156116 | 1935   |
+-------------+--------+
10 rows in set (0.01 sec)

二、将jack表的内容导入到txt文本中

mysql> select * from jack into outfile '/mysql/mysql5.5/load/data.txt' fields terminated by ',';
ERROR 1 (HY000): Can't create/write to file '/mysql/mysql5.5/load/data.txt' (Errcode: 13)
mysql> select * from jack into outfile '/mysql/mysql5.5/load/data.txt' fields terminated by ',';
Query OK, 1469199 rows affected (22.34 sec)

mysql> select count(*) from jack;
+----------+
| count(*) |
+----------+
|  1469199 |
+----------+
1 row in set (0.09 sec)

三、修改data.txt的属主

[root@rhel5 load]# chown oracle:oinstall data.txt
[root@rhel5 load]# more data.txt 
13400017749,4594
13400087049,5044
13400826615,83029
13400977755,22505
13401509025,2671

四、将data.txt导入到oracle表mysql中

[oracle@rhel5 ~]$ cd /u01/sqlload/
[oracle@rhel5 sqlload]$ cat mysql.ctl 
load data
infile '/mysql/mysql5.5/load/data.txt'
append into table mysql
  trailing nullcols
( id char terminated by ',',
  flow char terminated by whitespace)
[oracle@rhel5 sqlload]$ sqlldr jack/jack control='mysql.ctl' log=input.log direct=true

SQL*Loader: Release 11.2.0.1.0 - Production on 星期一 9月 23 15:15:57 2013

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


加载完成 - 逻辑记录计数 1469199

五、验证

SQL> select count(*) from mysql;

  COUNT(*)
----------
   1469199

SQL> select * from mysql where rownum < 10;

    ID     FLOW
---------- ----------
1.3400E+10     4594
1.3400E+10     5044
1.3401E+10    83029
1.3401E+10    22505
1.3402E+10     2671
1.3402E+10    10435
1.3402E+10     111061
1.3402E+10     2525
1.3402E+10    13204

已选择9行。
原文地址:https://www.cnblogs.com/Richardzhu/p/3334919.html