0
SEL COUNT(*) FROM DATABASE_A.QF 

Count = 37,011,480

SEL COUNT(*) FROM DATABASE_A_INC.QFA

Count = 368,454

Query 1

DELETE A
FROM 
    DATABASE_A.QF A,
    DATABASE_A_INC.QFA B
WHERE
    A.Q_NUM = B.Q_NUM
AND
    A.ID = B.ID 
AND 
    A.LOCATION_ID=1;

The above DELETE query runs into SPOOL space issue.

So I rewrote it in another form.

Query 2

DELETE FROM DATABASE_A.QF  A WHERE (Q_NUM,ID) IN 
(SELECT Q_NUM,ID FROM DATABASE_A_INC.QFA B) 
AND LOCATION_ID=1;

368454 rows processed. DELETE Command Complete

My questions:

  1. Are query 1 and 2 logically the same? Are they deleting the same records?
  2. How do I verify the count from Query 1 without running into a SPOOL space issue? I have tried a general COUNT function. I tried increasing spool space to a certain extent.
  3. Is there a better way to check the count for Query 1?
Siyual
  • 16,415
  • 8
  • 44
  • 58
Pirate X
  • 3,023
  • 5
  • 33
  • 60

1 Answers1

0

The queries are logically the same, yes. My guess is the reason for your SPOOL space issue is that you are listing your tables with commas instead of joining them. Try counting query 1 like this:

SELECT COUNT(*)
FROM DATABASE_A.QF A
INNER JOIN DATABASE_A_INC.QFA B ON A.Q_NUM = B.Q_NUM
WHERE A.ID = B.ID
AND A.LOCATION_ID=1;
kjmerf
  • 4,275
  • 3
  • 21
  • 29