简体   繁体   English

从Oracle中的表将大量数据导出到平面文件

[英]Export Huge Volume of Data to flat files from tables in Oracle

I am using Oracle 11g. 我正在使用Oracle 11g。 My requirement is to compare the data of two different db's. 我的要求是比较两个不同数据库的数据。 There are around 350 tables in each db and out of these 350 tables, approx 40 tables have more than 1 million records. 每个数据库中大约有350个表,在这350个表中,大约40个表的记录超过100万。 For data comparison, I wrote one perl script to compare using hash and tested with few files. 为了进行数据比较,我编写了一个perl脚本以使用哈希进行比较,并用很少的文件进行了测试。 Also, tried with unix awk command to check the performance and asked this forum on unix solution and got excellent help. 此外,还尝试使用unix awk命令检查性能,并要求此论坛提供有关unix解决方案的帮助,并获得了出色的帮助。

Now my problem is to find out the best way to extract data from Tables to files. 现在,我的问题是找出从表中提取数据到文件的最佳方法。
Both db's have same number of tables and each table will have same number of columns in both db ie the layout in both the db's is exactly the same. 两个数据库都有相同数量的表,并且每个表在两个数据库中都有相同数量的列,即两个数据库中的布局完全相同。
options which i think and searched are 我认为和搜寻的选项是
1) using sqlloader - I think performance will be bad in this case 1)使用sqlloader-我认为这种情况下性能会很差
2) using data pump - Not sure if i can extract few set of columns via sql by using data pump and load into text file 2)使用数据泵-不知道我是否可以通过使用数据泵通过sql提取几组列并将其加载到文本文件中
3) using bulk collect -- same as above. 3)使用批量收集-与上述相同。 Is it possible to extract each table and from each table set of columns. 是否可以从每个表的列集中提取每个表。 if yes, how can it be done. 如果是,该怎么办。 Also what would be the performance. 还有什么表现。
4) sqlplus or anything else. 4)sqlplus或其他任何东西。 I cannot download any software for this on my machine. 我无法在我的机器上下载任何软件。

Basic sql for selecting set of columns from each table for both the db's can be done easily. 从两个数据库的每个表中选择一组列的基本sql可以轻松完成。 I am looking at the best approach to export data into flat files. 我正在寻找将数据导出到平面文件的最佳方法。
Please suggest 请建议

You can do it in the database using DBMS_COMPARISON. 您可以使用DBMS_COMPARISON在数据库中进行操作。

http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_comparison.htm#CHDHEFFJ http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_comparison.htm#CHDHEFFJ

The fundamental approach that is the least expensive (to the developer for sure) is to compare sets of things rather than string evaluations of files. 最便宜的基本方法(对于开发人员来说肯定是最便宜的)是比较事物集而不是文件的字符串求值。 Nothing can compare sets of things faster (and in less code) than the database itself. 没有什么可以比数据库本身更快(和更少的代码)比较事物集的。 The use of database links and a wise use of the MINUS and INTERSECT operators is very powerful means towards this end. 为此,使用数据库链接以及明智地使用MINUS和INTERSECT运算符是非常有效的手段。

Try using the below SQL this should be the fastest approach as you will be working inside the database. 尝试使用下面的SQL,这将是最快的方法,因为您将在数据库中进行操作。 Access the table over the DB link in other database. 通过其他数据库中的DB链接访问表。

select * from ( ( select * from Table_In_Schema1 minus select * from Table_In_Schema2) union all ( select * from Table_In_Schema2 minus select * from Table_In_Schema1) ) 选择*从((从Table_In_Schema1选择*减去从Table_In_Schema2选择*)并集所有(从Table_In_Schema2选择*减去从Table_In_Schema1选择*))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM