DB2 日志文件限制,SQLCODE:-964

Posted

技术标签:

【中文标题】DB2 日志文件限制,SQLCODE:-964【英文标题】:DB2 Logfile Limitation, SQLCODE: -964 【发布时间】:2012-11-26 17:09:53 【问题描述】:

我在 DB2 中尝试了一个巨大的插入查询。 INSERT INTO MY_TABLE_COPY (SELECT * FROM MY_TABLE);

在此之前,我设置了以下内容:

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 

有什么建议吗?

【问题讨论】:

为什么不使用 DB/2 实用程序来卸载/加载表?实用程序不像简单的 INSERT 语句那样使用日志。对于这类事情,UNLOAD/LOAD 效率要高得多。请记住,您不能在 INSERT/SELECT 操作中间发出 COMMITS - 这一切都必须作为单个工作单元发生 - 对于大型表,这可能会使日志负担过重。 【参考方案1】:

我使用了 LOGFILSIZ、LOGPRIMARY 和 LOGSECOND 的最大值; 对于 Windows、Linux 等,LOGFILSIZ 的最大值可能不同。但是,您可以尝试一个非常大的数字,数据库会让您知道最大值是多少。就我而言,它是 262144。

另外,LOGPRIMARY + LOGSECOND

【讨论】:

【参考方案2】:

您可以将这些 INSERT 语句放在带有提交间隔的存储过程中,而不是使用 DB CFG 参数进行反复试验。

有关详细信息,请参阅以下帖子:这可能会有所帮助。

https://prasadspande.wordpress.com/2014/06/06/plsql-ways-updatingdeleting-the-bulk-data-from-the-table/

谢谢

【讨论】:

以上是关于DB2 日志文件限制,SQLCODE:-964的主要内容,如果未能解决你的问题,请参考以下文章

DB2日志满解决办法

如何从 db2 中的 diaglog 获取特定的错误日志

用于从文本日志文件中提取/检索值的 Shell 脚本(sqlcode 字段值)

SQLCODE=-668, SQLSTATE=57016, SQLERRMC=7

DB2 SQL error: SQLCODE: -1585, SQLSTATE: 54048, SQLERRMC: null

db2怎么删除数据库的事务日志