473,396 Members | 1,784 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,396 software developers and data experts.

how to compare two tables difference

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 whether
the test output run with right data)
Nov 12 '05 #1
10 27435
"xixi" <da****@yahoo.com> wrote in message
news:c0**************************@posting.google.c om...
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 whether
the test output run with right data)


Do the tables have a primary key or unique index (with no null values)?
Nov 12 '05 #2
On Wed, 30 Jun 2004 21:39:08 UTC, da****@yahoo.com (xixi) wrote:
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 whether
the test output run with right data)


how about something like

select
*
from table_test a
where not exists (
select 1 from original_table b where a.col1 = b.col1 and a.col2 =
b.col2 and a.col3 = b.col3)

--
Lorne Sunley
Nov 12 '05 #3
I usually do:
T1 EXCEPT T2
UNION ALL
T2 EXCEXT T1

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4
da****@yahoo.com (xixi) wrote in message news:<c0**************************@posting.google. com>...
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 whether
the test output run with right data)

You can use EXCEPT operator.
Nov 12 '05 #5
"Serge Rielau" <sr*****@ca.eye-be-em.com> wrote in message
news:cc**********@hanover.torolab.ibm.com...
I usually do:
T1 EXCEPT T2
UNION ALL
T2 EXCEXT T1


EXCEPT ALL is better if your tables have no keys.

and don't forget the brackets otherwise you will be doing
(((T1 EXCEPT ALL T2) UNION ALL T2) EXCEPT ALL T1) !
with a(a) as (values (1), (1),(2))
, b(b) as (values(1),(2),(2))
(select * from a
except ALL
select * from b)
union all
(select * from b
except ALL
select * from a)
;

1
-----------
2
1

2 record(s) selected.

with a(a) as (values (1), (1), (2))
, b(b) as (values(2),(2),(1))
(select * from a
except
select * from b)
union all
(select * from b
except
select * from a)
;

1
-----------

0 record(s) selected.

Regards
Paul Vernon
Business Intelligence, IBM Global Services
Nov 12 '05 #6
Hello,

Can BLOB field of DB2 store TEXT string data ?

Thanks inadvacne !

Shum
www.mingyik.com
"Paul Vernon" <pa*********@ukk.ibmm.comm> ¦b¶l¥ó
news:cc***********@gazette.almaden.ibm.com ¤¤¼¶¼g...
"Serge Rielau" <sr*****@ca.eye-be-em.com> wrote in message
news:cc**********@hanover.torolab.ibm.com...
I usually do:
T1 EXCEPT T2
UNION ALL
T2 EXCEXT T1


EXCEPT ALL is better if your tables have no keys.

and don't forget the brackets otherwise you will be doing
(((T1 EXCEPT ALL T2) UNION ALL T2) EXCEPT ALL T1) !
with a(a) as (values (1), (1),(2))
, b(b) as (values(1),(2),(2))
(select * from a
except ALL
select * from b)
union all
(select * from b
except ALL
select * from a)
;

1
-----------
2
1

2 record(s) selected.

with a(a) as (values (1), (1), (2))
, b(b) as (values(2),(2),(1))
(select * from a
except
select * from b)
union all
(select * from b
except
select * from a)
;

1
-----------

0 record(s) selected.

Regards
Paul Vernon
Business Intelligence, IBM Global Services

Nov 12 '05 #7
yes , we do have unqiue index on one of the columns.

"Mark A" <no****@nowhere.com> wrote in message news:<cu*****************@news.uswest.net>...
"xixi" <da****@yahoo.com> wrote in message
news:c0**************************@posting.google.c om...
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 whether
the test output run with right data)


Do the tables have a primary key or unique index (with no null values)?

Nov 12 '05 #8
if i have null value in one of the table column, what should i do?
Nov 12 '05 #9
if i have null value in one of the table column and don't want to
compare it, what should i do?

"Paul Vernon" <pa*********@ukk.ibmm.comm> wrote in message news:<cc***********@gazette.almaden.ibm.com>...
"Serge Rielau" <sr*****@ca.eye-be-em.com> wrote in message
news:cc**********@hanover.torolab.ibm.com...
I usually do:
T1 EXCEPT T2
UNION ALL
T2 EXCEXT T1


EXCEPT ALL is better if your tables have no keys.

and don't forget the brackets otherwise you will be doing
(((T1 EXCEPT ALL T2) UNION ALL T2) EXCEPT ALL T1) !
with a(a) as (values (1), (1),(2))
, b(b) as (values(1),(2),(2))
(select * from a
except ALL
select * from b)
union all
(select * from b
except ALL
select * from a)
;

1
-----------
2
1

2 record(s) selected.

with a(a) as (values (1), (1), (2))
, b(b) as (values(2),(2),(1))
(select * from a
except
select * from b)
union all
(select * from b
except
select * from a)
;

1
-----------

0 record(s) selected.

Regards
Paul Vernon
Business Intelligence, IBM Global Services

Nov 12 '05 #10
Shum [MingYik] wrote:
Hello,

Can BLOB field of DB2 store TEXT string data ?


Yes, it can. But DB2 will treat it like binary data.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: serge | last post by:
Is there a stored procedure to allow me to compare two SQL objects? In my case for example I want to compare two stored procedures on two different databases? If there is no SP that does...
4
by: Maur | last post by:
Hi all, I have 2 tables say t_OLD and t_NEW. The new has corrections for audit purposes. They are identical in all respects (i.e. new is a copy of old and then changes are made to t_new) ...
2
by: Rachel Curran | last post by:
Please can anybody help me with the following: I have two separate excel spreadsheets that I have imported into access, each sheet holds the same fields. Both spreadsheets hold all information...
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...
8
by: Vincent | last post by:
has any one seen a program to compare mdbs'. I have ran into a few of them, but none seem to really do that job. Basically what I need to do is, take 2 access mdb's and check the differences...
2
by: ethoemmes | last post by:
I have 2 tables (tblSAPDetails & tblVendorDetails) they both have Vendor as the PK. I would like to run a query which would highligh the differences between the 2 tables on 2 fields (ABC and...
2
by: malini | last post by:
I have two tables emp - ( has two field) Name Sal Joe 45 Jack 50 Kate 67 Dept Name Dept Sal Joe IS 46
1
by: cssExp | last post by:
Hi, Assume i have two tables. "accounts" and "accounts_logs" "accounts" (accid, type) "accounts_log" (accid, ip, timestamp) Here i want to choose a radom 3 accids from "accounts" if...
3
by: alter.fire | last post by:
Hey im trying to do the following in PHP: Connect to 2 different databases, one named complete and one incomplete. My goal is to find whats missing in the "incomplete" database. The fields...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.