If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Alternative to MQT

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-22-07, 21:56
palchuri palchuri is offline
Registered User
 
Join Date: Jan 2003
Posts: 47
Alternative to MQT

I have a table called PTBalance with the following columns

a) Acct_Nbr
b) Acct_Type
c) Currency
d) Balance

I want to have a table(Physical also fine) having the following data

a) Acct_nbr
b) Sum(Balance)

Every day PTBalance table is replaced by a new table(drop the existing one, create a new one with latest data)


I created a MQT with acct_nbr and Sum(balance) then I try to delete the base table, db2 did n't allow me because it has MQT reference.

1)

Is there any other utility in DB2 which does not keep reference to base tables?


2) Can I create a physical table not MQT by using Create table as select statement. Can I use group by as part of select criteria?

3) What is the difference between MQT and Create table as select?



Thanks in advance.
Shri
__________________
p.srinivasarao
Reply With Quote
  #2 (permalink)  
Old 08-22-07, 22:21
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
The data in an MQT is periodically refreshed (either every time the data in the underlying tables is changed, or when you issue issue a refesh table command).
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 08-22-07, 22:31
palchuri palchuri is offline
Registered User
 
Join Date: Jan 2003
Posts: 47
Thanks for the reply. I have a requirement to create a summary table or MQT or some utility with no reference to base tables bcz base tables are recreated every day.

If I use MQT , I can't drop base table. Is there any approach in db2 create a table from some sql and no reference to base tables.

Thanks
Shri
__________________
p.srinivasarao
Reply With Quote
  #4 (permalink)  
Old 08-23-07, 03:41
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Why do you recreate the base table every day? You could just truncate it.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 08-23-07, 06:46
palchuri palchuri is offline
Registered User
 
Join Date: Jan 2003
Posts: 47
Unfortunatly yes, we load the data into a intermediate tables and swap with original table.
__________________
p.srinivasarao
Reply With Quote
  #6 (permalink)  
Old 08-23-07, 07:27
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Then you could also construct the new MQT after the load and swap that with the original one.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 08-23-07, 16:58
palchuri palchuri is offline
Registered User
 
Join Date: Jan 2003
Posts: 47
Thats a good question, But the table has 4-6 Millions of records which might take some time. During that period user won't be able to access neither base table nor MQT.

Is there any way I can construct a intermediate table with no reference to the base table.

SELECT ACCOUNTNUMBER,-1*SUM(TRADEBALANCE) as TRADEBALANCE
FROM PTBALANCE GROUP BY ACCOUNTNUMBER

Out put of the above query should be added to intermediate table with no reference to the base table.

Let me know if additional information is required.
__________________
p.srinivasarao
Reply With Quote
  #8 (permalink)  
Old 08-23-07, 23:15
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
How about loading from a cursor?
Reply With Quote
  #9 (permalink)  
Old 08-24-07, 23:38
palchuri palchuri is offline
Registered User
 
Join Date: Jan 2003
Posts: 47
I read the documentation for Cursors. It exactly satisfies our requirements. I don't see any documentation on the performance of this cursor utility. Please provide me if you have any?


Thanks for your help all of you.


Shri
__________________
p.srinivasarao
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On