473,385 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

compare data between tables in test and production

how to compare data between tables and views row by row , column by column in the test and production environment
Mar 1 '07 #1
11 11500
jigs
7
you can create a DB link from test to PROD.

do the minus of 2 tables to get the difference
Mar 2 '07 #2
vijaydiwakar
579 512MB
how to compare data between tables and views row by row , column by column in the test and production environment
pls explain in detail and give me thy tbl structure ,relations if any and some data from the tbls
Mar 3 '07 #3
you can create a DB link from test to PROD.

do the minus of 2 tables to get the difference

Hi
I dont want a generalised result , the minus query lists out al the differences.
here say if i have
table a (Test)
col1(Pk) col2(Businesskey) col3(Business key) col4 col5
1 ABC XYZ 1 2
2 BCA XXX 5 6
3 AAA YYY 3 3
4 EFG HIJ 4 5


table a (Prod)
col1(Pk) col2(Businesskey) col3(Business key) col4 col5
1 ABC XYZ 1 2
2 BCA YYY 5 6
3 AAA YYY 2 2
4 GFE JIH 7 8

if the structure looks some wat like this (My identifier are the business keys and not the Primary keys)
then i want the result dispalyed like this

Row existing in test and not in prod
4 EFG HIJ 4 5

Row existing in prod and not in test
4 GFE JIH 7 8

Rows Existing in both but not matching
2 BCA XXX 5 6 (Test)
2 BCA YYY 5 6 (Prod)
3 AAA YYY 3 3 (Test)
3 AAA YYY 2 2 (Prod)

i want to write a generic procedure for the same which can give me these results. the input of the procedure will be the table names , columns names and the Db link

Can u pls help me with this
Mar 21 '07 #4
pls explain in detail and give me thy tbl structure ,relations if any and some data from the tbls

Hi
I dont want a generalised result , the minus query lists out al the differences.
here say if i have
table a (Test)
col1(Pk) col2(Businesskey) col3(Business key) col4 col5
1 ABC XYZ 1 2
2 BCA XXX 5 6
3 AAA YYY 3 3
4 EFG HIJ 4 5


table a (Prod)
col1(Pk) col2(Businesskey) col3(Business key) col4 col5
1 ABC XYZ 1 2
2 BCA YYY 5 6
3 AAA YYY 2 2
4 GFE JIH 7 8

if the structure looks some wat like this (My identifier are the business keys and not the Primary keys)
then i want the result dispalyed like this

Row existing in test and not in prod
4 EFG HIJ 4 5

Row existing in prod and not in test
4 GFE JIH 7 8

Rows Existing in both but not matching
2 BCA XXX 5 6 (Test)
2 BCA YYY 5 6 (Prod)
3 AAA YYY 3 3 (Test)
3 AAA YYY 2 2 (Prod)

i want to write a generic procedure for the same which can give me these results. the input of the procedure will be the table names , columns names and the Db link

CAn u help me with this
Mar 21 '07 #5
vijaydiwakar
579 512MB
Hi
I dont want a generalised result , the minus query lists out al the differences.
here say if i have
table a (Test)
col1(Pk) col2(Businesskey) col3(Business key) col4 col5
1 ABC XYZ 1 2
2 BCA XXX 5 6
3 AAA YYY 3 3
4 EFG HIJ 4 5


table a (Prod)
col1(Pk) col2(Businesskey) col3(Business key) col4 col5
1 ABC XYZ 1 2
2 BCA YYY 5 6
3 AAA YYY 2 2
4 GFE JIH 7 8

if the structure looks some wat like this (My identifier are the business keys and not the Primary keys)
then i want the result dispalyed like this

Row existing in test and not in prod
4 EFG HIJ 4 5

Row existing in prod and not in test
4 GFE JIH 7 8

Rows Existing in both but not matching
2 BCA XXX 5 6 (Test)
2 BCA YYY 5 6 (Prod)
3 AAA YYY 3 3 (Test)
3 AAA YYY 2 2 (Prod)

i want to write a generic procedure for the same which can give me these results. the input of the procedure will be the table names , columns names and the Db link

CAn u help me with this
select * from table1 t1 ,table2 t2
where t1.col2<>t2.col2 and t1.col3<>t2.col3

and so on add ur columns here
Mar 21 '07 #6
select * from table1 t1 ,table2 t2
where t1.col2<>t2.col2 and t1.col3<>t2.col3

and so on add ur columns here

The query that u have given gives me a very generic result.
I want a procedure which takes the table name and the column names as input
and the out put is more like a report from where i can identify wat is the problem
If i list all the columns in the query it will give me the entire record set
this doesn solve my purpose
Mar 21 '07 #7
amr
20
select col4,col5
from test
minus
select col4,col5
from prod;
Mar 24 '07 #8
i want to make a procedure which takes the tablename,columnnames as input.
from the system tables we somehow find the unique index on the table and then have generic joins on the same
i am not quite sure as to how will i come up with such a generic procedure.
I want a specific result set.
Mar 27 '07 #9
Just An algo of wat i want to do and am not really sure how
Proc(tablename(to be compared) , columnnames(that need to be compared), Business keys (or saythe unique indexeshere its col2 and col3))
1) Do a record matching analysis
Find the no of records matching based on Business keys
that ll be done by putting a join some wat like this
select l.col2,l.col3,r.col2,r.col3,'Test' as TableName from testa l, proda r where l.col2 = r.col2 and l.col3 = r.col3 union
select l.col2,l.col3,r.col2,r.col3,'Prod' as TableName from testa l, proda r where l.col2 = r.col2 and l.col3 = r.col3

2) & 3) the records present in one prod not in test and vice versa can be found out using
select col2,col3,'Test' as TABLENAME from ((select col2,col3 from testa minus (select l.col2,l.col3 from testa l, proda r where l.col2 = r.col2 or l.col3 = r.col3)))
UNION
select col2,col3,'Prod' as TABLENAME from((select col2,col3 from proda minus (select r.col2,r.col3 from testa l, proda r where l.col2 = r.col2 or l.col3 = r.col3)))

4)find the records present in both but different
select col2,col3,'Test' as TABLENAME from
((select l.col2,l.col3 from testa l, proda r where l.col2 = r.col2 or l.col3 = r.col3) minus
(select l.col2,l.col3 from testa l, Proda r where l.col2=r.col2 and l.col3=r.col3))
union
select col2,col3,'Prod' as TABLENAME from
((select r.col2,r.col3 from testa l, proda r where l.col2 = r.col2 or l.col3 = r.col3) minus
(select r.col2,r.col3 from testa l, Proda r where l.col2=r.col2 and l.col3=r.col3))

after this i want to perform an analysis of the matching records on the non keys
that can be done by a join on all attributes.

end of algo

i want the entire thing to be generic , so that it can be used for any table
the no of columns and the business keys wil vary with every time
i want a generic way of taking the column names and the business keys as a string from user and put them in the queries in a very generic way
Mar 27 '07 #10
Another option is to use a database data comparison tool such as Zidsoft CompareData
Dec 21 '07 #11
amitpatel66
2,367 Expert 2GB
how to compare data between tables and views row by row , column by column in the test and production environment
The SET operations should really help you out:
Try this in test environment.

Expand|Select|Wrap|Line Numbers
  1. declare
  2. tab_name VARCHAR2(20);
  3. col_name VARCHAR2(20);
  4. emp_det emp%ROWTYPE;
  5. BEGIN
  6. tab_name:= &1;
  7. col_name:= &2;
  8.  
  9. EXECUTE IMMEDIATE 'SELECT '|| col_name|| ' FROM '|| tab_name INTERSECT 'SELECT '|| col_name|| ' FROM '|| tab_name||'@db_link' BULK COLLECT INTO emp_det;
  10. END;
  11.  
The above code will get you similra records from two tables of test and production instances. Do it similarly for getting uncommon rows.
Dec 24 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jeffrey Sheldon via SQLMonster.com | last post by:
I am debugging one of our programs and ran the fix in Test. I would like to compare table 1 between Production and Test. I want the query to output column 1 if Production <> Test output. What...
10
by: xixi | last post by:
we are using db2 udb v8.1 on windows, i would like to know whether we have tool or way to compare two tables on same database for data difference. thanks. (same ddl, different data, try to compare...
1
by: Dany | last post by:
I am trying to find a nice way to compare objects (tables, colums, indexes, primary and fk) between my production and my test dabatase. I would like to known if their are tricks or tools...
16
by: StenKoll | last post by:
Help needed in order to create a register of stocks in a company. In accordance with local laws I need to give each individual share a number. I have accomplished this by establishing three tables...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
0
by: Manystrengths | last post by:
I must warn all of you willing to help me that this is my first go at designing a functional data access page. Please bear in mind that we all start somewhere so if I should be asking the absolute...
5
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of...
4
by: SQLNewbie | last post by:
I have the following cursor that I am comparing 2 tables, the production table and a copy of the production table, I want results of all address's that are like the address1 field...the problem...
11
by: KK | last post by:
I have an application (Developed in MS access with two MDB's one for FE and another for BE) distributed to user group. We have new requirements that needs to modify the tables structures including...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.