SQL0668N Operation not allowed for reason code "3" on table "TEST". SQLSTATE=57016

时间:2022-08-21 10:01:20

问题描述:

查询,操作表都报如下错误

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 "" on table "test".
SQLSTATE=

第二:Load空文件对表进行terminate,出现以下错误。

[test@TEST-DB1 ~]$ db2 load from / of del terminate into test

Agent Type Node SQL Code Result
______________________________________________________________________________
LOAD + Success.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD + Success.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
LOAD - Init error. Table unchanged.
______________________________________________________________________________
RESULTS: of LOADs completed successfully.
______________________________________________________________________________ Summary of LOAD Agents:
Number of rows read =
Number of rows skipped =
Number of rows loaded =
Number of rows rejected =
Number of rows deleted =
Number of rows committed = 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('分区号')

执行完成!