問題描述:
查詢,操作表都報如下錯誤
SQL0668N Operation not allowed for reason code "3" on table "TEST". SQLSTATE=57016
操作步驟:
第一:執行reorg解鎖表,出現以下錯誤。
[test@TEST-DB1 ~]$ db2 "reorg table test" SQL0668N Operation not allowed for reason code "3" on table "test". SQLSTATE=57016
第二:Load空文件對表進行terminate,出現以下錯誤。
[test@TEST-DB1 ~]$ db2 load from / of del terminate into test Agent Type Node SQL Code Result ______________________________________________________________________________ LOAD 001 +00000000 Success. ______________________________________________________________________________ LOAD 002 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 003 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 004 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 005 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 006 +00000000 Success. ______________________________________________________________________________ LOAD 007 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 008 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 009 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 010 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 011 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 012 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 013 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 014 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 015 -00027902 Init error. Table unchanged. ______________________________________________________________________________ LOAD 016 -00027902 Init error. Table unchanged. ______________________________________________________________________________ RESULTS: 2 of 16 LOADs completed successfully. ______________________________________________________________________________ Summary of LOAD Agents: Number of rows read = 0 Number of rows skipped = 0 Number of rows loaded = 0 Number of rows rejected = 0 Number of rows deleted = 0 Number of rows committed = 0 SQL27902N LOAD RESTART/TERMINATE is not allowed on a table that is not in LOAD PENDING state.
一般上面兩步基本能解決表無法操作問題,不過也有的跟這次一樣無法完成,
分析可能是部分分區沒有進行terminate或者load時被強制殺了
第三:查詢分區表狀態
[test@TEST-DB1 ~]$ db2 -x "SELECT DBPARTITIONNUM FROM TABLE(SYSPROC.ADMIN_GET_TAB_INFO('TEST','TEST')) AS T where load_status='PENDING' "
挨個對上面查詢出的分區號進行terminate處理
[test@TEST-DB1 ~]$db2 load from /dev/null of del terminate into TEST.TEST partitioned db config OUTPUT_DBPARTNUMS('分區號')
執行完成!