2012-11-26 127 views
3

我試過DB2中的一個巨大的插入查詢。 INSERT INTO MY_TABLE_COPY(SELECT * FROM MY_TABLE);DB2日誌文件限制,SQLCODE:-964

在此之前,我設置如下:

UPDATE DATABASE CONFIGURATION FOR MY_DB USING LOGFILSIZ 70000; 
UPDATE DATABASE CONFIGURATION FOR MY_DB USING LOGPRIMARY 50; 
UPDATE DATABASE CONFIGURATION FOR MY_DB USING LOGSECOND 2; 
db2stop force; 
db2start; 

,我得到這個錯誤:

DB21034E The command was processed as an SQL statement because it was not a 
valid Command Line Processor command. During SQL processing it returned: 
SQL0964C The transaction log for the database is full. SQLSTATE=57011 

SQL0964C The transaction log for the database is full. 

Explanation: 

All space in the transaction log is being used. 

If a circular log with secondary log files is being used, an 
attempt has been made to allocate and use them. When the file 
system has no more space, secondary logs cannot be used. 

If an archive log is used, then the file system has not provided 
space to contain a new log file. 

The statement cannot be processed. 

User Response: 

Execute a COMMIT or ROLLBACK on receipt of this message (SQLCODE) 
or retry the operation. 

If the database is being updated by concurrent applications, 
retry the operation. Log space may be freed up when another 
application finishes a transaction. 

Issue more frequent commit operations. If your transactions are 
not committed, log space may be freed up when the transactions 
are committed. When designing an application, consider when to 
commit the update transactions to prevent a log full condition. 

If deadlocks are occurring, check for them more frequently. 
This can be done by decreasing the database configuration 
parameter DLCHKTIME. This will cause deadlocks to be detected 
and resolved sooner (by ROLLBACK) which will then free log 
space. 

If the condition occurs often, increase the database 
configuration parameter to allow a larger log file. A larger log 
file requires more space but reduces the need for applications to 
retry the operation. 

If installing the sample database, drop it and install the 
sample database again. 

sqlcode : -964 

sqlstate : 57011 

有什麼建議?

+1

你爲什麼不使用DB/2實用程序來卸載/加載你的桌子嗎?實用程序不像使用簡單的INSERT語句那樣使用日誌。 UNLOAD/LOAD對於這類事情來說效率更高。請記住,在INSERT/SELECT操作過程中不能發出COMMITS - 這一切都必須作爲單個工作單元進行 - 對於大型表格,這可能會使日誌負荷過重。 – NealB

回答

2

我使用了LOGFILSIZ,LOGPRIMARY和LOGSECOND的最大值; 對於Windows,Linux等,LOGFILSIZ的最大值可能不同。但是,您可以嘗試一個非常大的數字,並且DB會告訴您最大值是多少。在我的情況下,它是262144.

此外,LOGPRIMARY + LOGSECOND < = 256.我試着每個128,它適用於我的巨大查詢。