DB2 表空间简单说明_PHP教程

php中文网
发布: 2016-07-12 09:04:57
原创
1535人浏览过

美间AI
美间AI

美间AI:让设计更简单

美间AI 45
查看详情 美间AI

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)


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1071440.htmlTechArticleDB2 表空间简单说明 一、新建测试库: [db2inst2@localhost shell]$ db2 "create database ghan on /db2inst2/db2inst2 using codeset utf-8 territory cn collate using system...
相关标签:
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号