As mentioned in a couple other recent threads, I'm extremely new to Oracle, and I'm attempting to make some Access databases be much more efficient in pulling their data from an Oracle database server.
One question I have with this is in the SQL structure for creating a table.
Basically, we have an varchar field and a date field which we need to compare for a report pulled via Access. Currently, another large query is run, a table built (millions of records), then another query runs and deleted 99.9999% of the records. So, to me it would seem best to take care of the largest differentiating factor up front.
Here is the query before I add the part that is currently in a separate delete query (this part works for sure):
Then I initially was thinking of adding in the delete portion, well being the opposite of the delete query's criteria...
But then I got to thinking... what if I cut that rather large portion off up front and then compared THAT with the remainder of the query... I'd think that would be the most beneficial... So, here's my idea to do it that way:
I've not tested either of the last 2 scripts so far... have a meeting, and then after that I hope to test the latter. I'm thinking it'll be the winner of the options, but I'd like any critiques or suggestions any of you might have.
Thanks.
One question I have with this is in the SQL structure for creating a table.
Basically, we have an varchar field and a date field which we need to compare for a report pulled via Access. Currently, another large query is run, a table built (millions of records), then another query runs and deleted 99.9999% of the records. So, to me it would seem best to take care of the largest differentiating factor up front.
Here is the query before I add the part that is currently in a separate delete query (this part works for sure):
Code:
CREATE TABLE MyTestTable AS
SELECT a.BrNum ,a.Item ,a.STATUS ,a.UT4 ,a.UN5 ,a.UT3
,r.NAME ,r.SS_NO
,b.DID ,b.TID ,b.Ch ,b.NumFld
,b.DtFld ,b.CID ,b.DDt ,b.DSDt
FROM SysNm.Prts p
INNER JOIN
SysNm.AcctMain a
ON p.BrNum = a.BrNum
INNER JOIN
SysNm.AcctRel r
ON a.Item = r.Item
INNER JOIN
SysNm.Rbkp b
ON a.Item = b.Item
WHERE (p.PT <> '125') AND
(a.BrNum <> '50000') AND
(a.Resp = 'Mouse1') AND
(a.DID = 'Mouse1') AND
(b.DID = 'Mouse1');
Then I initially was thinking of adding in the delete portion, well being the opposite of the delete query's criteria...
Code:
CREATE TABLE MyTestTable AS
SELECT a.BrNum ,a.Item ,a.STATUS ,a.UT4 ,a.UN5 ,a.UT3
,r.NAME ,r.SS_NO
,b.DID ,b.TID ,b.Ch ,b.NumFld
,b.DtFld ,b.CID ,b.DDt ,b.DSDt
FROM SysNm.Prts p
INNER JOIN
SysNm.AcctMain a
ON p.BrNum = a.BrNum
INNER JOIN
SysNm.AcctRel r
ON a.Item = r.Item
INNER JOIN
SysNm.Rbkp b
ON a.Item = b.Item
WHERE (p.PT <> '125') AND
(a.BrNum <> '50000') AND
(a.Resp = 'Mouse1') AND
(a.DID = 'Mouse1') AND
(b.DID = 'Mouse1')[HIGHLIGHT] AND
(LEFT(b.NumFld,2 <> RIGHT(b.DtFld,2))[/HIGHLIGHT];
But then I got to thinking... what if I cut that rather large portion off up front and then compared THAT with the remainder of the query... I'd think that would be the most beneficial... So, here's my idea to do it that way:
Code:
CREATE TABLE MyTestTable AS
SELECT a.BrNum ,a.Item ,a.STATUS ,a.UT4 ,a.UN5 ,a.UT3
,r.NAME ,r.SS_NO
,b.DID ,b.TID ,b.Ch ,b.NumFld
,b.DtFld ,b.CID ,b.DDt ,b.DSDt
FROM SysNm.Prts p
INNER JOIN
SysNm.AcctMain a
ON p.BrNum = a.BrNum
INNER JOIN
SysNm.AcctRel r
ON a.Item = r.Item
INNER JOIN
[highlight](
SELECT x.DID ,x.TID ,x.Ch ,b.NumFld
x.DtFld ,x.CID ,x.Ddt ,x.DSDt
FROM SysNm.Rbkp x
WHERE (LEFT(b.NumFld,2 <> RIGHT(b.DtFld,2))
) b[/highlight]
ON a.Item = b.Item
WHERE (p.PT <> '125') AND
(a.BrNum <> '50000') AND
(a.Resp = 'Mouse1') AND
(a.DID = 'Mouse1') AND
(b.DID = 'Mouse1');
I've not tested either of the last 2 scripts so far... have a meeting, and then after that I hope to test the latter. I'm thinking it'll be the winner of the options, but I'd like any critiques or suggestions any of you might have.
Thanks.