DB2 自動儲存表空間(Automatic Storage)增加和刪除儲存路徑
阿新 • • 發佈:2019-02-05
本文舉例說明修改DB2自動儲存表空間storage group的辦法,如果您對storage group還不瞭解,請先參考連結。
原本storage group有path1和path2,目標增加一條路徑path3,並刪掉path2,測試如下:
檢視修改操作會對哪些表空間產生影響:
增加path3, 刪除path2,刪除之後,path2被會置為drop pending,再次刪除的話就會報錯SQL2092N:
最後需要一個Rebalance操作
說明:如果是臨時表空間,無法Rebalance, 需要刪掉並重建臨時表空間。
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0058603.html
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.dbobj.doc/doc/r0054957.html
原本storage group有path1和path2,目標增加一條路徑path3,並刪掉path2,測試如下:
$ db2 "CREATE STOGROUP sg ON 'C:\test\path1', 'C:\test\path2' "
$ db2 "create tablespace tbstest managed by automatic storage USING STOGROUP sg"
$ db2 "create table t1(id int) in tbstest"
$ db2 "insert into t1 values(100),(200)"
檢視修改操作會對哪些表空間產生影響:
$ db2 "SELECT substr(TBSP_NAME,1,30) as TBSP_NAME FROM table (MON_GET_TABLESPACE('', -2)) WHERE TBSP_USING_AUTO_STORAGE = 1 AND TBSP_CONTENT_TYPE IN ('ANY','LARGE') AND STORAGE_GROUP_NAME = 'SG' ORDER BY TBSP_ID" TBSP_NAME ------------------------------ TBSTEST 1 record(s) selected.
增加path3, 刪除path2,刪除之後,path2被會置為drop pending,再次刪除的話就會報錯SQL2092N:
$ db2 "alter STOGROUP sg add 'C:\test\path3'" $ db2 "alter STOGROUP sg drop 'C:\test\path2' " SQL2095W Storage path "C:\test\path2" is in the drop pending state because one or more automatic storage table spaces reside on the path. SQLSTATE=01691 $ db2 "alter STOGROUP sg drop 'C:\test\path2' " DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL2092N Storage path "C:\test\path2" is in the drop pending state. The current request cannot be processed. SQLSTATE=55073
最後需要一個Rebalance操作
$ db2 "alter tablespace tbstest rebalance" $ db2 "alter STOGROUP sg drop 'C:\test\path2'" DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL1051N The path "C:\test\path2" does not exist or is not valid. SQLSTATE=57019
說明:如果是臨時表空間,無法Rebalance, 需要刪掉並重建臨時表空間。
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0058603.html
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.dbobj.doc/doc/r0054957.html