LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-26-2010, 05:22 AM   #1
RB_ramesh
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Rep: Reputation: 0
How to compare oracle database table contains using scripts


How to compare oracle database table contains using (Perl/Shell)scripts.

Last edited by RB_ramesh; 12-26-2010 at 05:24 AM.
 
Old 12-27-2010, 02:59 AM   #2
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 326

Rep: Reputation: 67
Hi,

What do you mean by comparing?

From Perl you can interact with an Oracle database with DBI and DBD::Oracle modules.
You will need to install them as they are not defaultly installed.

Regards,

Tshimanga.
 
Old 12-28-2010, 09:30 AM   #3
RB_ramesh
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks Tshimanga.
Do we have any Perl scripts where I can compare my baseline excel file with database table contains?

Last edited by RB_ramesh; 12-28-2010 at 09:32 AM.
 
Old 12-29-2010, 10:15 AM   #4
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 326

Rep: Reputation: 67
Dear RB_ramesh,

You first need to tell us what you mean by comparing.
My guess is that you want to know if the whole contents of two different tables are identical. If this check is performed against all the user tables in the databases it will still exclude important database desing and organization such as the references, the triggers, the permissions ...
Let's take an examples

database_1_numbers_table
-------------------------
id integer primary key
french varchar(255)
english varchar(255)

Some records of this table being (in csv format)
3,trois,three
11,onze,eleven
10,dix,ten
73,septante-trois,seventy three
2010,deux miles dix,two thousands and ten

database_2_numbers_table
-------------------------
id integer primary key
french varchar(255)
english varchar(255)

Some records of this table being (in csv format)
13,treize,thirteen
11,onze,eleven
10,dix,ten
73,septante-trois,seventy three
1986,mille neuf cents quatre-vingt-six,one thousands and eighty six

With this sample clearly the two tables are different.

If this is what you want then I will draft a Perl script for you. But I first need you to confirm.

Besides, have you installed the Perl modules DBI and DBD::Oracle?

Regards,

Tshimanga.
 
Old 12-29-2010, 04:09 PM   #5
benali72
Member
 
Registered: Aug 2007
Posts: 32

Rep: Reputation: 0
Use the Oracle MINUS set operator

You can see if two Oracle tables contain identical rows by two SQL statements. Just use the MINUS operator.

This will be way easier than comparing tables by scripting (with Perl or whatever).

Example --

SELECT * FROM table_A
MINUS
SELECT * FROM table_B;

then --

SELECT * FROM table_B
MINUS
SELECT * FROM table_A;


If both statements return the null set (zero rows) the tables are identical. (BTW, you could combine the two statements into one using UNION but I kept it simple).

See -- http://www.orafaq.com/wiki/Minus
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl: Want to compare CGI input with data from a MySQL table resetreset Programming 1 11-20-2008 07:58 AM
Reading a CSV text file and storing the values in Oracle Database table shafi2all Linux - Newbie 3 04-17-2008 01:19 PM
LXer: Oracle(R) Database Standard Edition One and Oracle Enterprise Linux on HP Set New World Record for Price Performance with TPC-C Benchmark LXer Syndicated Linux News 0 06-12-2007 06:01 PM
Difference between Oracle Server and Oracle Database ganninu Programming 3 02-27-2007 02:06 AM
Linux Startup Scripts for Oracle Application & Database research2004 Linux - Newbie 1 04-14-2004 06:22 AM


All times are GMT -5. The time now is 08:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration