2012-10-29 57 views
0

我在終端上運行了以下db2腳本,沒有任何問題。但是當我嘗試訪問與此表有關的實際前端頁面時,出現錯誤(代碼爲),表明該表處於非活動狀態。我重新啓動了db2,但仍然存在這個問題。修補程序後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. 
+0

這和Java有什麼關係? –

+0

通常Java開發人員比其他人更喜歡db2的東西! – ComeRun

+0

您可以添加一些相關信息嗎? – gks

回答

2

這是最好看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