LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-15-2017, 01:45 PM   #1
RithanyaLaxmi
LQ Newbie
 
Registered: Feb 2016
Posts: 3

Rep: Reputation: Disabled
Compare tables record count from 2 different databases via shellscript


Hi,

I want to compare the records count of around 200 tables from db1 with record count of same 200 tables from db2 thro she'll script, please let me know how we can do it in a simplified way using shellscript as we are planning to schedule this , any code snippet on this is really helpful. Since there ar 200 tables , we need to reduce the time as much as possible as well. Please provide your input with code snippet/ examples which will surely help us in this case.

Thanks.
 
Old 03-15-2017, 01:51 PM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,655
Blog Entries: 3

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
Yes, some of your code would help. Please show what you have started with and explain your approach so that we may provide advice. Also show some sample records from each table or explain how they are stored. Are they flat, tab separated values? Or are they in some kind of SQL database? We'll help you but not do your work for you, besides some of our hourly rates would scare you.
 
Old 03-16-2017, 07:32 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,354
Blog Entries: 13

Rep: Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411
Hi and welcome to LQ.

Please realize that forum members are here as volunteers and the way LQ works is that these volunteers are here to help you as you attempt to solve your own problem.

Therefore it is prudent that you show what you have tried and where you are stuck. People will certainly be willing to offer suggestions and improvements to you work, but people are not here to write your scripts for you.

Please post your code that you have.
 
Old 03-16-2017, 12:45 PM   #4
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 945

Rep: Reputation: 216Reputation: 216Reputation: 216
This looks like a very standard requirement for instance to test the integrity of a data base copy that first you should look for an existing solution in the help fora of your data base.

Still, if you want to do it in a shell script,
First
Is the list of "around 200 tables" fixed (so you can put it into a list or is is to be taken from the data dictionary by something like select tablename from iitables.. . Append the result to a 3 column array with the table name in the first column.

Next open (prepare .. whatever) the 2 data bases.
Cycle the array by index.
col2[index]=select count * from col1[index] from the first data base
col3[index]=select count * from col1[index] from the second data base
If the result differs, print the error message
Loop

Clearly this is just an idea without knowing about your database, resources etc.

Do try and let us know.

OK

Last edited by AnanthaP; 03-16-2017 at 12:48 PM.
 
  


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
Compare and Update 2 columns from 2 tables in mysql sam@ Linux - Newbie 5 06-11-2015 02:58 AM
MySQL - Query and compare 2 tables rookiepaul Programming 4 05-12-2008 09:05 AM
Mysql Compare two tables from different databases baddah Programming 4 04-20-2006 12:36 AM
mysql count tables in a database Longinus Programming 2 04-11-2004 01:22 AM
Need to compare 2 databases. Help please! morbid_ru Programming 1 12-08-2003 04:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:09 PM.

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
Open Source Consulting | Domain Registration