修补程序后db2表处于非活动状态

时间:2012-10-29 03:35:56

标签: database db2

我在终端上运行了以下db2脚本没有问题。但是当我尝试访问此表所涉及的实际前端页面时,我收到错误(代码 57016 ),表明该表处于非活动状态。我重新启动了db2但仍然出现了这个问题。

任何人都可以帮助我吗

alter table CUSTOMER alter column Delivery set default 0! 
alter table CUSTOMER alter column Delivery set not null! 

alter table CUSTOMER add constraint pref_ck4 check (Delivery between 0 and 1)!

commit!
quit!

并且回滚是:

alter table CUSTOMER alter Delivery drop DEFAULT!
alter table CUSTOMER alter COLUMN Delivery drop NOT NULL!

alter table CUSTOMER drop constraint pref_ck4!

reorg table CUSTOMER!

commit!
quit!

我收到的错误:

UncategorisedDatabaseException: Query=[SELECT * FROM CUSTOMER WHERE ID = ?], database       vendor error message is: DB2 SQL error: SQLCODE: -668, SQLSTATE: 57016, SQLERRMC: 7;CUSTOMER, UncategorisedDatabaseException errorCode = -668

db2 => ? 57016

SQLSTATE 57016: The table cannot be accessed, because it is inactive.

1 个答案:

答案 0 :(得分:3)

最好查看SQLCODE和SQLERRMC以了解具体错误。 SQLSTATE不能唯一标识错误。

SQLCODE -668是SQL0668N; SQLERRMC(7;CUSTOMER)表示它是由于CUSTOMER表上的原因码7所致。

要查找this error,您可以使用DB2客户端的方便引用:

$ db2 "? sql0668n"


SQL0668N  Operation not allowed for reason code "<reason-code>" on table
      "<table-name>".

Explanation: 

Access to table "<table-name>" is restricted. The cause is based on the
following reason codes "<reason-code>": 

[...]

7        
         The table is in the reorg pending state. This can occur after
         an ALTER TABLE statement containing a REORG-recommended
         operation.

[...]

User response:

[...]

7        
         Reorganize the table using the REORG TABLE command.

         For a table in the reorg pending state, note that the following
         clauses are not allowed when reorganizing the table:

         *  The INPLACE REORG TABLE clause
         *  The ON DATA PARTITION clause for a partitioned table when
            table has nonpartitioned indexes defined on the table

解决方案是在桌面上运行REORG