Question

I have an Oracle database with a table called "Persons". It holds the data you'd expect, such as Person_ID, name, address, phone number etc...

I also have an excel document with similar data. I need to carry out some investigative work for a potential migration task in the future. The excel doc does NOT have any unique ID style identifiers, just names/address/phone numbers.

I have the idea of trying to export the Oracle table as .xls/.csv and trying to compare it/ highlight matches it has with the excel document. Is there a way of doing this? I assume there is a way to export a table aswell?

Thanks!

Was it helpful?

Solution

One way of doing this is to:

Start by creating a table in Oracle where you can insert the excel data into the database. You can use something like this:

CREATE TABLE excel_dump AS SELECT * FROM Persons WHERE 1 = 0;

Then in excel you can create a column to hold an insert statement - so if column A holds Person_ID values and column B holds name values then, for the first row, you can use:

="INSERT INTO excel_dump (Person_ID, name) VALUES ( "&A1&", '"&SUBSTITUTE(B1,"'", "''") &"' );"

Add more columns as appropriate (numeric fields can be concatenated without any issues, as per the A1 cell, but text fields should be wrapped in SUBSTITUTE( ?, "'", "''" ) so that any single quotes in the data are escaped, as per the B1 cell). Then copy that for each row.

Copy and paste the insert statements generated from those rows into your favourite oracle client (SQL Developer / SQL*Plus / Toad etc) to populate the excel_dump table.

Then you can do whatever investigations you want comparing the two tables. So if you want to see the rows from the excel spreadsheet which do not match the rows in the Persons table then you can do something like:

SELECT Person_ID, Name FROM excel_dump
MINUS
SELECT Person_ID, Name FROM Persons;

Or some more complex analysis as you find appropriate.

Alternately

If you are using SQL Developer, then it has an option to import data from an Excel spreadsheet.

OTHER TIPS

This sounds to me like a good fit for an ETL tool. I am personally fond of the Pentaho Data Integration utility available in their open-source Community edition, but there are many options in the same market.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top