Heim  >  Artikel  >  php教程  >  DB2 表空间简单说明

DB2 表空间简单说明

WBOY
WBOYOriginal
2016-06-13 08:50:561107Durchsuche

DB2 表空间简单说明

一、新建测试库:

[db2inst2@localhost shell]$ db2 "create database ghan on /db2inst2/db2inst2 using codeset utf-8 territory cn collate using system"
DB20000I CREATE DATABASE 命令成功完成。

[db2inst2@localhost shell]$ db2 connect to ghan


数据库连接信息


数据库服务器 = DB2/LINUXX8664 9.7.5
SQL 授权标识 = DB2INST2
本地数据库别名 = GHAN


[db2inst2@localhost shell]$




二、新建缓冲池:

[db2inst2@localhost shell]$ db2 "create bufferpool bp32k pagesize 32k"
DB20000I SQL 命令成功完成。
[db2inst2@localhost shell]$


db2inst2@localhost ~]$ db2 "SELECT * FROM SYSCAT.BUFFERPOOLS"


BPNAME BUFFERPOOLID DBPGNAME NPAGES PAGESIZE ESTORE NUMBLOCKPAGES BLOCKSIZE NGNAME
-------------------------------------------------------------------------------------------------------------------------------- ------------ -------------------------------------------------------------------------------------------------------------------------------- ----------- ----------- ------ ------------- ----------- --------------------------------------------------------------------------------------------------------------------------------
IBMDEFAULTBP 1 - -2 4096 N 0 0 -
BP32K 2 - -2 32768 N 0 0 -


2 条记录已选择。



三、新建数据库管理(DMS)大表空间

[db2inst2@localhost shell]$ db2 -tsvf create_tabs.sql
create large tablespace tbs_data pagesize 32k managed by database using (file '/db2inst2/data_tb/cont0' 100M, file '/db2inst2/data_tb/cont1' 100M) EXTENTSIZE 32 prefetchsize automatic bufferpool bp32k no file system caching
DB20000I SQL 命令成功完成。

[db2inst2@localhost shell]$ cd /db2inst2/data_tb/
[db2inst2@localhost data_tb]$ ll
总计 205008
-rw------- 1 db2inst2 db2inst2 104857600 10-20 08:48 cont0
-rw------- 1 db2inst2 db2inst2 104857600 10-20 08:48 cont1
[db2inst2@localhost data_tb]$


1、重设DMS表空间大小
alter tablespace tbs_data extend (file '/db2inst2/data_tb/cont0' 100M, file '/db2inst2/data_tb/cont1' 500M)

四、新建临时表空间


[db2inst2@localhost shell]$ db2 "create temporary tablespace tbs_temp pagesize 32k managed by system using ('/db2inst2/data_tb/tab_temp') bufferpool bp32k"
DB20000I SQL 命令成功完成。
[db2inst2@localhost shell]$

[db2inst2@localhost tab_temp]$ db2 "create user temporary tablespace tbs_usertemp pagesize 32k managed by system using ('/db2inst2/data_tb/tab_usertemp') bufferpool bp32k"
DB20000I SQL 命令成功完成。
[db2inst2@localhost tab_temp]$

五、新建自动管理表空间

[db2inst2@localhost tab_temp]$ db2 "create tablespace tab_data2 initialsize 100M increasesize 100M MAXSIZE 10G"
DB20000I SQL 命令成功完成。
[db2inst2@localhost tab_temp]$
[db2inst2@localhost tab_temp]$ db2 "create tablespace tab_data3 pagesize 32k bufferpool bp32k"
DB20000I SQL 命令成功完成。
[db2inst2@localhost tab_temp]$

六、新建DMS管理表空间

CREATE TABLESPACE tab_sp4 MANAGED BY DATABASE USING (FILE '/db2inst2/data_tb/tab_sp4' 100M)

七、添加数据库层自动管理存储

[db2inst2@localhost autodb]$ db2 "alter database ghan add storage on '/db2inst2/autodb'"
DB20000I SQL 命令成功完成。
[db2inst2@localhost autodb]$ db2pd -d ghan -storagepaths




八、将DMS表空间修改来自动存储管理表空间


[db2inst2@localhost T0000008]$ db2 " ALTER TABLESPACE tab_sp4 MANAGED BY AUTOMATIC STORAGE"
DB20000I SQL 命令成功完成。
[db2inst2@localhost T0000008]$ db2 "alter tablespace tab_sp4 rebalance"
DB20000I SQL 命令成功完成。
[db2inst2@localhost T0000008]$ db2pd -d ghan -tablespaces


[db2inst2@localhost ~]$ db2pd -d ghan -tablespaces


Database Partition 0 -- Database GHAN -- Active -- Up 0 days 00:00:05 -- Date 10/22/2015 03:02:24


Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002B810664E400 0 DMS Regular 4096 4 Yes 4 1 1 Off 1 0 3 SYSCATSPACE
0x00002B810664FB80 1 SMS SysTmp 4096 32 Yes 64 1 1 On 2 0 31 TEMPSPACE1
0x00002B81066534C0 2 DMS Large 4096 32 Yes 32 1 1 Off 1 0 31 USERSPACE1
0x00002B8106654C40 3 DMS Large 4096 4 Yes 4 1 1 Off 1 0 3 SYSTOOLSPACE
0x00002B81066563C0 4 DMS Large 32768 32 Yes 64 2 2 Off 2 0 31 TBS_DATA
0x00002B8106657D40 5 SMS SysTmp 32768 32 Yes 32 2 2 On 1 0 31 TBS_TEMP
0x00002B810665B480 6 SMS UsrTmp 32768 32 Yes 32 2 2 On 1 0 31 TBS_USERTEMP
0x00002B810665EBC0 7 DMS Large 4096 32 Yes 64 1 1 Off 2 0 31 TAB_DATA2
0x00002B8106660540 8 DMS Large 32768 32 Yes 64 2 2 Off 2 0 31 TAB_DATA3
0x00002B8106661EC0 9 DMS Large 4096 32 Yes 64 1 1 Off 2 0 31 TAB_SP4


Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002B810664E400 0 24576 24572 22884 0 1688 22884 22884 0x00000000 0 0 No
0x00002B810664FB80 1 2 2 2 0 0 0 0 0x00000000 0 0 No
0x00002B81066534C0 2 8192 8160 96 0 8064 96 96 0x00000000 0 0 No
0x00002B8106654C40 3 8192 8188 152 0 8036 152 152 0x00000000 0 0 No
0x00002B81066563C0 4 6400 6336 96 0 6240 96 96 0x00000000 0 0 No
0x00002B8106657D40 5 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002B810665B480 6 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002B810665EBC0 7 51200 51136 96 0 51040 96 96 0x00000000 0 0 No
0x00002B8106660540 8 2048 1984 96 0 1888 96 96 0x00000000 0 0 No
0x00002B8106661EC0 9 256 192 96 0 96 96 96 0x00000000 0 0 No


Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002B810664E400 0 Yes Yes 33554432 -1 No None None No
0x00002B810664FB80 1 Yes No 0 0 No 0 None No
0x00002B81066534C0 2 Yes Yes 33554432 -1 No None None No
0x00002B8106654C40 3 Yes Yes 33554432 -1 No None None No
0x00002B81066563C0 4 No No 0 0 No 0 None No
0x00002B8106657D40 5 No No 0 0 No 0 None No
0x00002B810665B480 6 No No 0 0 No 0 None No
0x00002B810665EBC0 7 Yes Yes 104857600 104857600 No 10737418240 None No
0x00002B8106660540 8 Yes Yes 33554432 -1 No None None No
0x00002B8106661EC0 9 Yes Yes 786432 -1 No None None No


Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002B810664F940 0 0 File 24576 24572 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000000/C0000000.CAT
0x00002B8106651060 1 0 Path 1 1 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000001/C0000000.TMP
0x00002B8106651270 1 1 Path 1 1 1 0 /db2inst2/autodb/db2inst2/NODE0000/GHAN/T0000001/C0000001.TMP
0x00002B8106654A00 2 0 File 8192 8160 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000002/C0000000.LRG
0x00002B8106656180 3 0 File 8192 8188 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000003/C0000000.LRG
0x00002B8106657900 4 0 File 3200 3168 - 0 /db2inst2/data_tb/cont0
0x00002B8106657B10 4 1 File 3200 3168 - 0 /db2inst2/data_tb/cont1
0x00002B8106659220 5 0 Path 1 1 - 0 /db2inst2/data_tb/tab_temp
0x00002B810665C960 6 0 Path 1 1 - 0 /db2inst2/data_tb/tab_usertemp
0x00002B8106660100 7 0 File 25600 25568 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000007/C0000000.LRG
0x00002B8106660310 7 1 File 25600 25568 1 0 /db2inst2/autodb/db2inst2/NODE0000/GHAN/T0000007/C0000001.LRG
0x00002B8106661A80 8 0 File 1024 992 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000008/C0000000.LRG
0x00002B8106661C90 8 1 File 1024 992 1 0 /db2inst2/autodb/db2inst2/NODE0000/GHAN/T0000008/C0000001.LRG
0x00002B8106663400 9 0 File 128 96 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000009/C0000000.LRG
0x00002B8106663610 9 1 File 128 96 1 0 /db2inst2/autodb/db2inst2/NODE0000/GHAN/T0000009/C0000001.LRG




九、关于表空间quiesce测试

[db2inst2@localhost ~]$ db2 quiesce tablespaces FOR table empl share
DB20000I QUIESCE TABLESPACES 命令成功完成

[db2inst2@localhost ~]$ db2 -tsvf create-tm.sql
CREATE TABLE EMPLdd (ENO INTEGER, LASTNAME VARCHAR(30),HIREDATE DATE, SALARY INTEGER) IN TAB_SP4
DB21034E 该命令被当作 SQL
语句来处理,因为它是无效的“命令行处理器”命令。在 SQL
处理期间,它返回:
SQL0290N 不允许访问表空间。 SQLSTATE=55039




表空间标识 = 9
名称 = TAB_SP4
类型 = 数据库管理空间
内容 = 所有持久数据。大型表空间。
状态 = 0x0001
详细解释:
已停顿:SHARE
总计页数 = 8448
可用页数 = 8384
已用页数 = 5504
可用页数 = 2880
高水位标记(页) = 5504
页大小(以字节计) = 4096
扩展数据块大小(页) = 32
预取大小(页) = 64
容器数 = 2
停顿者的数目 = 1
停顿者 1 :
表空间标识 = 9
对象标识 = 4



[db2inst2@localhost ~]$ db2 quiesce tablespaces FOR table empl reset
DB20000I QUIESCE TABLESPACES 命令成功完成。
[db2inst2@localhost ~]$ db2 -tsvf create-tm.sql
CREATE TABLE EMPLdd (ENO INTEGER, LASTNAME VARCHAR(30),HIREDATE DATE, SALARY INTEGER) IN TAB_SP4
DB20000I SQL 命令成功完成。


[db2inst2@localhost ~]$

表空间标识 = 9
名称 = TAB_SP4
类型 = 数据库管理空间
内容 = 所有持久数据。大型表空间。
状态 = 0x0000
详细解释:
正常
总计页数 = 8448
可用页数 = 8384
已用页数 = 5568
可用页数 = 2816
高水位标记(页) = 5568
页大小(以字节计) = 4096
扩展数据块大小(页) = 32
预取大小(页) = 64
容器数 = 2

[db2inst2@localhost ~]$ db2 drop table empl
DB20000I SQL 命令成功完成。
[db2inst2@localhost ~]$ db2 list tablespaces show detail

表空间标识 = 9
名称 = TAB_SP4
类型 = 数据库管理空间
内容 = 所有持久数据。大型表空间。
状态 = 0x0000
详细解释:
正常
总计页数 = 8448
可用页数 = 8384
已用页数 = 160
可用页数 = 8224
高展数据块大小(页) = 32
预取大小(页) = 64
容器数 = 2


[db2inst2@localhost ~]$ db2 "alter tablespace tab_sp4 lower high water mark"
DB20000I SQL 命令成功完成。



表空间标识 = 9
名称 = TAB_SP4
类型 = 数据库管理空间
内容 = 所有持久数据。大型表空间。
状态 = 0x0000
详细解释:
正常
总计页数 = 8448
可用页数 = 8384
已用页数 = 160
可用页数 = 8224
高水位标记(页) = 160
页大小(以字节计) = 4096
扩展数据块大小(页) = 32
预取大小(页) = 64
容器数 = 2


水位标记(页) = 5568
页大小(以字节计) = 4096


[db2inst2@localhost ~]$ db2 -tsvf showtables
select substr(tbsp_name,1,20) as TABLESPACE_NAME,substr(tbsp_content_type,1,10) as TABLESPACE_TYPE,sum(tbsp_total_size_kb)/1024 as TOTAL_MB,sum(tbsp_used_size_kb)/1024 as USED_MB,sum(tbsp_free_size_kb)/1024 as FREE_MB,tbsp_page_size AS PAGE_SIZE from SYSIBMADM.TBSP_UTILIZATION group by tbsp_name,tbsp_content_type,tbsp_page_size order by 1


TABLESPACE_NAME TABLESPACE_TYPE TOTAL_MB USED_MB FREE_MB PAGE_SIZE
-------------------- --------------- -------------------- -------------------- -------------------- -----------
SYSCATSPACE ANY 96 89 6 4096
SYSTOOLSPACE LARGE 32 0 31 4096
TAB_DATA2 LARGE 200 0 199 4096
TAB_DATA3 LARGE 64 3 59 32768
TAB_SP4 LARGE 33 0 32 4096
TBS_DATA LARGE 200 3 195 32768
TBS_TEMP SYSTEMP 0 0 0 32768
TBS_USERTEMP USRTEMP 0 0 0 32768
TEMPSPACE1 SYSTEMP 0 0 0 4096
USERSPACE1 LARGE 32 0 31 4096


10 条记录已选择。
[db2inst2@localhost ~]$ db2 -tsvf insert.sql
INSERT INTO EMPL WITH DT(ENO) AS (VALUES(1) UNION ALL SELECT ENO+1 FROM DT WHERE ENO DB21034E 该命令被当作 SQL
语句来处理,因为它是无效的“命令行处理器”命令。在 SQL
处理期间,它返回:
SQL0289N 未能在表空间 "TBS_DATA" 中分配新页面。 SQLSTATE=57011

[db2inst2@localhost ~]$ db2 -tsvf showtables
select substr(tbsp_name,1,20) as TABLESPACE_NAME,substr(tbsp_content_type,1,10) as TABLESPACE_TYPE,sum(tbsp_total_size_kb)/1024 as TOTAL_MB,sum(tbsp_used_size_kb)/1024 as USED_MB,sum(tbsp_free_size_kb)/1024 as FREE_MB,tbsp_page_size AS PAGE_SIZE from SYSIBMADM.TBSP_UTILIZATION group by tbsp_name,tbsp_content_type,tbsp_page_size order by 1


TABLESPACE_NAME TABLESPACE_TYPE TOTAL_MB USED_MB FREE_MB PAGE_SIZE
-------------------- --------------- -------------------- -------------------- -------------------- -----------
SYSCATSPACE ANY 96 89 6 4096
SYSTOOLSPACE LARGE 32 0 31 4096
TAB_DATA2 LARGE 200 0 199 4096
TAB_DATA3 LARGE 64 3 59 32768
TAB_SP4 LARGE 33 0 32 4096
TBS_DATA LARGE 200 198 0 32768
TBS_TEMP SYSTEMP 0 0 0 32768
TBS_USERTEMP USRTEMP 0 0 0 32768
TEMPSPACE1 SYSTEMP 0 0 0 4096
USERSPACE1 LARGE 32 0 31 4096


10 条记录已选择。
[db2inst2@localhost ~]$

表空间标识 = 4
名称 = TBS_DATA
类型 = 数据库管理空间
内容 = 所有持久数据。大型表空间。
状态 = 0x0000
详细解释:
正常
总计页数 = 6400
可用页数 = 6336
已用页数 = 6336
可用页数 = 0
高水位标记(页) = 6336
页大小(以字节计) = 32768
扩展数据块大小(页) = 32
预取大小(页) = 64
容器数 = 2


DMS表空间添加容器:

alter tablespace tbs_data extend (file '/db2inst2/data_tb/cont0' 100M, file '/db2inst2/data_tb/cont1' 500M)


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn