0

我在终端上运行了以下 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.
4

1 回答 1

3

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

SQLCODE-668是 SQL0668N;SQLERRMC ( 7;CUSTOMER) 表明这是由于 CUSTOMER 表上的原因代码 7 造成的。

要查找此错误,您可以使用来自 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在您的桌子上运行。

于 2012-10-30T00:22:22.723 回答