今天一個同事報告一個問題,表都不能使用了,檢查了一下,發現
問題 db2 => select * from test
ACTNO ACTKWD ACTDESC
------ ------ --------------------
SQL0290N Table space access is not allowed. SQLSTATE=55039
其他表也不能使用
在db2cc裡查看表空間狀態為: 停頓的獨占
解決方法:
到命令行狀態,首先connect 到需要處理的數據庫
◆1、db2 => list tablespaces show detail 顯示表空間狀態
Tablespaces for Current Database
Tablespace ID = 0
Name = SYSCATSPACE
Type = System managed space
Contents = Any data
State = 0x0000
Detailed explanation:
Normal
Total pages = 2519
Useable pages = 2519
Used pages = 2519
Free pages = Not applicable
High water mark (pages) = Not applicable
Page size (bytes) = 4096
Extent size (pages) = 32
Prefetch size (pages) = 32
Number of containers = 1
Tablespace ID = 1
Name = TEMPSPACE1
Type = System managed space
Contents = System Temporary data
State = 0x0000
Detailed explanation:
Normal
Total pages = 1
Useable pages = 1
Used pages = 1
Free pages = Not applicable
High water mark (pages) = Not applicable
Page size (bytes) = 4096
Extent size (pages) = 32
Prefetch size (pages) = 32
Number of containers = 1
Tablespace ID = 2
Name = USERSPACE1
Type = System managed space
Contents = Any data
State = 0x0004 這個代碼意義就是“停頓的獨占”,正常狀態為0x0000,
非0就是有問題,都可以用下面方法解決。
Detailed explanation:
Quiesced: EXCLUSIVE
Total pages = 687
Useable pages = 687
Used pages = 687
Free pages = Not applicable
High water mark (pages) = Not applicable
Page size (bytes) = 4096
Extent size (pages) = 32
Prefetch size (pages) = 32
Number of containers = 1
Number of quiescers = 1 注意下面幾行
Quiescer 1:
Tablespace ID = 2
Object ID = 50 “object id是造成死鎖表的id”
◆2、db2 => select tabname from syscat.tables where tableid=50 通過所住的id號找出是哪個表。
TABNAME
--------------------------------------------
SYSINDEXEXTENSIONPARMS
TEST 就是這個表
2 record(s) selected.
◆3、db2 => quiesce tablespaces for table test reset 執行該命令清除錯誤的狀態
DB20000I The QUIESCE TABLESPACES command completed successfully.
◆4、重新select,問題解決
◆5、比較常見導致改種問題的原因是,非正常的中止正對表進行的操作,導致對表空間的使用沒有正常的釋放。