2018.11.19 html
客戶遇到一個問題,在import數據的時候,產生了大量的日誌,客戶的數據庫是HADR模式,經過評估,這幾張表是能夠容許在備庫上不查詢的,表中的數據時臨時的。sql
方案一:修改腳本,將import修改成load |
方案二:修改腳本,不修改導入數據的方式,臨時激活表的not logged initially特性,事務級別 |
方案三:將相關的表重建,建立表,並激活not logged initially,該方案表將永久修改成not logged initially |
三種方案結果都是同樣的,因爲不寫日誌,均會致使備庫表沒法查詢,報錯SQL1477N數據庫
如今存在一個疑問,假如使用方案二,同時 import 時使用 commitcount,會不會存在問題呢 ? 針對該問題,獲得下面結論app
alter table t activate not logged initially; import from t.del of del commitcount 10 insert into t;
經過驗證 commitcount 10 會致使 activate not logged initially 失效。less
因此將 commitcount 10 取消掉,這個參數對於該場景,意義不大,因爲表不寫日誌,一旦事務失敗均會致使表不可訪問。dom
編輯m.sql文件 connect to sample; alter table t activate not logged initially; import from t.del of del insert into t; commit; db2 +c -tvf m.sql
中英文ide
https://www.ibm.com/support/knowledgecenter/zh/SSEPGG_11.1.0/com.ibm.db2.luw.admin.ha.doc/doc/c0006079.htmlui
https://www.ibm.com/support/knowledgecenter/da/SSEPGG_11.1.0/com.ibm.db2.luw.admin.ha.doc/doc/c0006079.htmlthis
附錄1:spa
https://www-01.ibm.com/support/docview.wss?uid=swg21215818
How to temporarily turn logging off for heavy change operations, such as insert, delete, update, and changes in indexes?
Tables being modified can be altered to activate the 'NOT LOGGED INITIALLY' attribute, which deactivates logging for the current unit of work. Any changes made to the table by an INSERT, DELETE, UPDATE, CREATE INDEX, DROP INDEX, or ALTER TABLE in the same unit of work after the table is altered by this statement are not logged.
At the completion of the current unit of work, the NOT LOGGED INITIALLY attribute is deactivated for the table and all operations that are done on the table in subsequent units of work are logged.
To use this option properly, the application doing the changes should NOT have AUTOCOMMIT enabled. Having AUTOCOMMIT OFF also helps define the scope of the transactions:
- For CLP, you can turn AUTOCOMMIT OFF using the registry variable DB2OPTIONS: