Chinaunix首页 | 论坛 | 博客
  • 博客访问: 315560
  • 博文数量: 33
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 385
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-06 18:57
个人简介

一个人总要走陌生的路,看陌生的风景,听陌生的歌,然后在某个不经意的瞬间,你会发现,原本费尽心机想要忘记的事情真的就这么忘记了--2007年2月 古之成大事者,不唯有超世之才,亦唯有坚韧不拔之志也!--2013年

文章分类
文章存档

2014年(7)

2013年(26)

我的朋友

分类: DB2/Informix

2013-01-16 14:21:54

1.创建数据库

db2 "create database testdb automatic storage yes on /dbauto dbpath on /database using codeset UTF-8 territory cn collate using system"

dbpath on 表示数据库目录 using codeset   XXXX terriory XXX 指定数据库编码集和区域


1.1显示实例下创建的数据库 

db2 list db directory


2.数据库连接

db2 connect to testdb

3.创建缓冲池

db2 "create bufferpool bp32k size 10000 pagesize 32k"   size表示页数,pagesize表示页大小,size*pagesize就是缓冲池的内存大小


4.创建数据库管理(DMS)的数据表空间

 db2 "create large tablespace tbs_data pagesize 32k managed by database using (file '/data1/tbs_data/cont0' 100M, file '/data1/tbs_data/cont1' 100M) extentsize 32 prefetchsize automatic bufferpool bp32k no file system caching"


5.创建系统管理(SMS)的临时表空间

db2 "create temporary tablespace tbs_temp pagesize 32k mamaged by system using  ('/data1/tbs_temp')  bufferpool bp32k"

using 指定表空间的容器,SMS支持的容器类型只是目录

6.创建(SMS)管理的用户临时表空间

db2 "create user temporary tablespace tbs_user_temp pagesize 32k managed by system using ('/data1/tbs_usertemp') bufferpool bp32k"


7.创建自动存储管理(Automatic Storage)的表空间

7.1 db2 "create tablespace tbs_index pagesize 32k bufferpool bp32k"

7.2 db2 "create tablespace tbs_data2 initialsize 100M increasesize 100M maxsize 1000G"

只有建库时启用了automatic storage yes,表空间才支持自动存储管理


8.显示每个表空间核心信息

db2 list tablespaces

8.1显示指定表空间相关信息

db2 list tablespace containers for show detail

8.2比list tablespaces更详细的显示表空间信息

db2 get snapshot for tablespaces on


9.显示表空间的配置信息,使用情况和容器信息

db2pd -d tablespaces


10.表空间容器的更改

10.1alter tablespace add/drop/extend/reduce/resize 

//add和drop操作,表空间会发生数据重新平衡(rebalance),对于reduce和resize操作,需要确保更改后的表空间容器有足够的空间,否则db2会拒绝该操作。

10.2alter tablespace begin new stripe set

//begin new stripe set 选项是当已有容器使用完后,再使用新增加的容器,该选项不会在容器间做Rebalance ,不会对系统造成性能影响,但它会造成数据偏移。

使用方法:db2 "db2 alter tablespace data_ts2 add(file '/data1/ts2/cont2' 50G)"

10.3db2 alter database db_name add storage on db_path3

//对于自动存储管理的表空间,无法在表空间级进行容器更改,只能在数据库级别,因为自动存储路径是在建库时指定的。可以使用add storage on 选项为数据库添加新的存储路径。

阅读(5487) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~