程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> DB2數據庫 >> DB2教程 >> DB2數據庫表的解鎖

DB2數據庫表的解鎖

編輯:DB2教程

下面為您介紹DB2數據庫中,如何才能將數據庫表進行解鎖,供您參考,希望對您有所幫助。

在DB2的命令行中輸入:

update monitor switches using lock on table on

然後打開另一個DB2命令窗口執行我的那個被吊死的Update語句。

然後在第一個DB2命令窗口執行:

get snapshot for locks on Database_Name(你的數據庫的名字)> locks.TXT

然後,可以看到第一個DB2的窗口有一個信息輸出,把這些信息輸出到TXT中,大致如下:

應用程序句柄                    = 36 
應用程序標識                    = AC100C47.IC05.00F6C6095828 
序號                          = 0246 
應用程序名                      = Java.exe 
CONNECT 授權標識                = DB2ADMIN 
應用程序狀態                    = UOW 正在等待 
狀態更改時間                    = 未收集 
應用程序代碼頁                  = 1208 
掛起的鎖定                      = 0 
總計等待時間(毫秒)            = 0

應用程序句柄                    = 43 
應用程序標識                    = *LOCAL.DB2.060512054331 
序號                          = 2273 
應用程序名                      = Java.exe 
CONNECT 授權標識                = DB2ADMIN 
應用程序狀態                    = 聯合請求暫掛 
狀態更改時間                    = 未收集 
應用程序代碼頁                  = 1208 
掛起的鎖定                      = 6 
總計等待時間(毫秒)            = 0

鎖定列表 
鎖定名稱                       = 0x031F9052000000000000000055 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 255 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部 
方式                           = S

鎖定名稱                       = 0x26800000000000000000000044 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部 
方式                           = S

鎖定名稱                       = 0x020006000F1700000000000052 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x00000001 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 5903 
對象類型                       = 行 
表空間名                       = USERSPACE1 
表模式                         = DB2ADMIN 
表名                           = C_USER 
方式                           = NS

鎖定名稱                       = 0x01000000010000000500BC0056 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部變化鎖定 
方式                           = S

鎖定名稱                       = 0x535953534E333030FD965C0641 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部方案鎖定 
方式                           = S 鎖定名稱                       = 0x02000600000000000000000054 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x00000001 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 6 
對象類型                       = 表 
表空間名                       = USERSPACE1 
表模式                         = DB2ADMIN 
表名                           = C_USER 
方式                           = IS

應用程序句柄                    = 557 
應用程序標識                    = *LOCAL.DB2.060512053913 
序號                          = 1254 
應用程序名                      = Java.exe 
CONNECT 授權標識                = DB2ADMIN 
應用程序狀態                    = 聯合請求暫掛 
狀態更改時間                    = 未收集 
應用程序代碼頁                  = 1208 
掛起的鎖定                      = 6 
總計等待時間(毫秒)            = 0

鎖定列表 
鎖定名稱                       = 0x031F9052000000000000000055 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 255 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部 
方式                           = S

鎖定名稱                       = 0x26800000000000000000000044 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部 
方式                           = S

鎖定名稱                       = 0x02000600071D00000000000052 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x00000001 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 7431 
對象類型                       = 行 
表空間名                       = USERSPACE1 
表模式                         = DB2ADMIN 
表名                           = C_USER 
方式                           = NS

鎖定名稱                       = 0x01000000010000000500BC0056 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部變化鎖定 
方式                           = S

鎖定名稱                       = 0x535953534E333030FD965C0641 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部方案鎖定 
方式                           = S

鎖定名稱                       = 0x02000600000000000000000054 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x00000001 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 6 
對象類型                       = 表 
表空間名                       = USERSPACE1 
表模式                         = DB2ADMIN 
表名                           = C_USER 
方式                           = IS

其中應用程序句柄43和557的狀態都是死鎖了,猜測是這2個應用爭用DB2的表,造成死鎖,根據日志提示,在DB2的命令窗口輸入:

force application (43)

force application (557)

提示這個操作是異步的,我執行list applicaions,結果進程中還有那2個進程,那2個進程可能是在執行比較大的操作,需要耐心等待,如何還不行,則使用下面的命令來強制所有的應用都停止,然後重啟DB2:

force application all

terminate

db2stop force

db2start

如果DB2在Window上,則可以使用“控制中心”->實例->右鍵“應用程序”,可以看到當前的鎖定情況,並且可以強行關閉某個進程,也可以顯示“鎖定鏈”。 
 

在DB2的命令行中輸入:

update monitor switches using lock on table on

然後打開另一個DB2命令窗口執行我的那個被吊死的Update語句。

然後在第一個DB2命令窗口執行:

get snapshot for locks on Database_Name(你的數據庫的名字)> locks.TXT

然後,可以看到第一個DB2的窗口有一個信息輸出,把這些信息輸出到TXT中,大致如下:

應用程序句柄                    = 36 
應用程序標識                    = AC100C47.IC05.00F6C6095828 
序號                          = 0246 
應用程序名                      = Java.exe 
CONNECT 授權標識                = DB2ADMIN 
應用程序狀態                    = UOW 正在等待 
狀態更改時間                    = 未收集 
應用程序代碼頁                  = 1208 
掛起的鎖定                      = 0 
總計等待時間(毫秒)            = 0

應用程序句柄                    = 43 
應用程序標識                    = *LOCAL.DB2.060512054331 
序號                          = 2273 
應用程序名                      = Java.exe 
CONNECT 授權標識                = DB2ADMIN 
應用程序狀態                    = 聯合請求暫掛 
狀態更改時間                    = 未收集 
應用程序代碼頁                  = 1208 
掛起的鎖定                      = 6 
總計等待時間(毫秒)            = 0

鎖定列表 
鎖定名稱                       = 0x031F9052000000000000000055 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 255 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部 
方式                           = S

鎖定名稱                       = 0x26800000000000000000000044 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部 
方式                           = S

鎖定名稱                       = 0x020006000F1700000000000052 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x00000001 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 5903 
對象類型                       = 行 
表空間名                       = USERSPACE1 
表模式                         = DB2ADMIN 
表名                           = C_USER 
方式                           = NS

鎖定名稱                       = 0x01000000010000000500BC0056 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部變化鎖定 
方式                           = S

鎖定名稱                       = 0x535953534E333030FD965C0641 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部方案鎖定 
方式                           = S

鎖定名稱                       = 0x02000600000000000000000054 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x00000001 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 6 
對象類型                       = 表 
表空間名                       = USERSPACE1 
表模式                         = DB2ADMIN 
表名                           = C_USER 
方式                           = IS

應用程序句柄                    = 557 
應用程序標識                    = *LOCAL.DB2.060512053913 
序號                          = 1254 
應用程序名                      = Java.exe 
CONNECT 授權標識                = DB2ADMIN 
應用程序狀態                    = 聯合請求暫掛 
狀態更改時間                    = 未收集 
應用程序代碼頁                  = 1208 
掛起的鎖定                      = 6 
總計等待時間(毫秒)            = 0

鎖定列表 
鎖定名稱                       = 0x031F9052000000000000000055 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 255 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部 
方式                           = S

鎖定名稱                       = 0x26800000000000000000000044 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部 
方式                           = S

鎖定名稱                       = 0x02000600071D00000000000052 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x00000001 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 7431 
對象類型                       = 行 
表空間名                       = USERSPACE1 
表模式                         = DB2ADMIN 
表名                           = C_USER 
方式                           = NS

鎖定名稱                       = 0x01000000010000000500BC0056 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部變化鎖定 
方式                           = S

鎖定名稱                       = 0x535953534E333030FD965C0641 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x40000000 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 0 
對象類型                       = 內部方案鎖定 
方式                           = S

鎖定名稱                       = 0x02000600000000000000000054 
鎖定屬性                       = 0x00000000 
發行版標志                     = 0x00000001 
鎖定計數                       = 1 
掛起計數                       = 0 
鎖定對象名                     = 6 
對象類型                       = 表 
表空間名                       = USERSPACE1 
表模式                         = DB2ADMIN 
表名                           = C_USER 
方式                           = IS

其中應用程序句柄43和557的狀態都是死鎖了,猜測是這2個應用爭用DB2的表,造成死鎖,根據日志提示,在DB2的命令窗口輸入:

force application (43)

force application (557)

提示這個操作是異步的,我執行list applicaions,結果進程中還有那2個進程,那2個進程可能是在執行比較大的操作,需要耐心等待,如何還不行,則使用下面的命令來強制所有的應用都停止,然後重啟DB2:

force application all

terminate

db2stop force

db2start

如果DB2在Window上,則可以使用“控制中心”->實例->右鍵“應用程序”,可以看到當前的鎖定情況,並且可以強行關閉某個進程,也可以顯示“鎖定鏈”。 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved