Compare millions of records from Oracle to SQL server
NickName:Mahajan344 Ask DateTime:2016-01-15T14:09:49

Compare millions of records from Oracle to SQL server

I have an Oracle database and a SQL Server database. There is one table say Inventory which contains millions of rows in both database tables and it keeps growing.

I want to compare the Oracle table data with the SQL Server data to find out which records are missing in the SQL Server table on daily basis.

Which is best approach for this?

  1. Create SSIS package.
  2. Create Windows service.

I want to consume less resource to achieve this functionality which takes less time and less resource.

Eg : 18 millions records in oracle and 16/17 millions in SQL Server

This situation of two different database arise because two different application online and offline

EDIT : How about connecting SQL server from oracle through Oracle Gateway to SQL server to

1) Direct query to SQL server from Oracle to update missing record in SQL server for 1st time.

2) Create a trigger on Oracle which gets executed when record is deleted from Oracle and it insert deleted record in new oracle table.

3) Create SSIS package to map newly created oracle table with SQL server to update SQL server record.This way only few records have to process daily through SSIS.

What do you think of this approach ?

Copyright Notice:Content Author:「Mahajan344」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/34805268/compare-millions-of-records-from-oracle-to-sql-server

Answers
Mike Honey 2016-01-17T21:51:04

I would create an SSIS package and load the data from the Oracle table use a Data Flow / OLE DB Data Source. If you have SQL Enterprise, the Attunity Connectors are a bit faster. \n\nThen I would load key from the SQL Server table into a Lookup transformation, where I would match the 2 sources on the key, and direct unmatched rows into a separate output.\n\nFinally I would direct the unmatched rows output to a OLE DB Command, to update the SQL Server table.\n\nThis SSIS package will require a lot of memory, but as the matching is done in memory with minimal IO, it will probably outperform other solutions for speed. It will need enough free memory to cache all the keys from the SQL Server Table.\n\nSSIS also has the advantage that it has lots of other transformation functions available if you need them later.",


Nick.McDermaid 2016-01-20T01:33:04

What you basically want to do is replication from Oracle to SQL Server.\n\nYou could do this in SSIS, A windows Service or indeed a multitude of platforms. \nThe real trick is using the correct design pattern.\n\nThere are two general design patterns \n\n\nSnapshot Replication\n\n\nYou take all records from both systems and compare them somewhere (so far we have suggestions to compare in SSIS or compare on Oracle but not yet a suggestion to compare on SQL Server, although this is valid)\n\nYou are comparing 18 million records here so this is a lot of work\n\n\nDifferential replication\n\n\nYou record the changes in the publisher (i.e. Oracle) since the last replication then you apply those changes to the subscriber (i.e. SQL Server)\n\nYou can do this manually by implementing triggers and log tables on the Oracle side, then use a regular ETL process (SSIS, command line tools, text files, whatever), probably scheduled in SQL Agent to apply these to the SQL Server.\n\nOr you could do this by using the out of the box replication capability to set up Oracle as a publisher and SQL as a subscriber: https://msdn.microsoft.com/en-us/library/ms151149(v=sql.105).aspx\n\nYou're going to have to try a few of these and see what works for you.\n\nGiven this objective:\n\n\n \n I want to consume less resource to achieve this functionality which takes less time and less resource\n \n\n\ntransactional replication is far more efficient but complicated. For maintenance purposes, which platforms (.Net, SSIS, Python etc.) are you most comfortable with?",


JLC 2016-01-17T17:10:04

Other alternatives:\n\nIf you can use Oracle gateway for SQL Server then you do not need to transfer data and can make the query directly.\n\nIf you can't use Oracle gateway, you can use Pentaho data integration or another ETL tool to compare tables and get results. Is easy to use.",


Md. Shamim Al Mamun 2016-01-19T16:59:06

I think the best approach is using oracle gateway.Just follow the steps. I have similar type of experience.\n\n\nInstall and Configure Oracle Database Gateway for SQL Server.\nhttps://docs.oracle.com/cd/B28359_01/gateways.111/b31042/installsql.htm\nNow you can create a dblink from oracle to sql server.\nCreate a procedure which compare the missing records in oracle database and insert into sql server database.\n\n\nFor example, you can use this statement inside your procedure.\n\n INSERT INTO \"dbo\".\"sql_server_table\"@dblink_name(\"column1\",\"column2\"....\"column5\")\nVALUES\n(\n select column1,column2....column5 from oracle_table\n minus\n select \"column1\",\"column2\"....\"column5\" from \"dbo\".\"sql_server_table\"@dblink_name\n)\n\n\n\nCreate a scheduler which execute the procedure daily.\n\n\nWhen both databases are online, missing records will be inserted to sql server. Otherwise the scheduler fail or you can execute the procedure manually.\nIt takes minimum resource.",


More about “Compare millions of records from Oracle to SQL server” related questions

Compare millions of records from Oracle to SQL server

I have an Oracle database and a SQL Server database. There is one table say Inventory which contains millions of rows in both database tables and it keeps growing. I want to compare the Oracle table

Show Detail

SSIS with millions of data to compare from source and target

I am trying to learn about SSIS and have few doubts regarding to that. I have want to compare 2 tables.1 table is in Sql Server and another is in Oracle. Both table will have same schema like bel...

Show Detail

How to insert millions of data of different RDBMS in to SQL Server database with insert statement?

I have two databases in my SQL Server with each database containing 1 single table as of now. I have 2 database like below : 1) Db1 (MySQL) 2) Db2 (Oracle) Now what I want to do is fill my data...

Show Detail

How to replicate tables from Oracle to SQL Server

We have an Oracle server in sister-company that is a bottleneck for our SQL Server-based business process. When we use SSIS to query all tables we need, it completes in 5 hours (millions of records...

Show Detail

How to efficiently stream millions of records from .NET to SQL Server

I have a C# .NET program that processes millions of records a few at a time and then stores them either in a flat file or a SQL Server database. Currently, to store them in the SQL Server database...

Show Detail

extract millions of records from sql server and load into oracle database using python script

I am extracting millions of data from sql server and inserting into oracle db using python. It is taking 1 record to insert in oracle table in 1 sec.. takes hours to insert. What is the fastest app...

Show Detail

Join SQL Server and Oracle Data

I need a help on SSIS. I have a table called Orders with millions of records. It have a column called OrderID. This is in SQL Server. I have a similar table called Orders with again millions of r...

Show Detail

Transactional replication from Oracle to SQL Server

We have an Oracle OLTP system and a SQL Server reporting solution. We run nightly stored procedures to extract the data using linked server but it it very slow as it is transferring millions of rec...

Show Detail

Common SQL to compare dates in SQL Server and ORACLE

I need to include a date comparison in my query where I compare a date string to a DATETIME column but i need it to work on both ORACLE and SQL Server and not have two separate queries. Are there any

Show Detail

Compare tables in SQL Server and Oracle

I have a set of SQL scripts to migrate data from tables in SQL Server 2005 to Oracle 11. I want to compare the data in two databases to ensure that they are migrated correctly. My source is: SQL S...

Show Detail