【DB2学习文档之六】数据库操作

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

1.创建数据库
db2 create database db_name
2.删除数据库
db2 drop database db

3.连接数据库
db2 connect to sample
4.断开数据库连接
connect reset
terminate(这个命令会结束整个会话和前端进程,并且它是唯一能保证一定把后端进程关闭的结束命令)
(上述两个可以在有工作进行时断开)
Disconnect
(有工作进行则不能断开)
5.备份数据库
要检查一下活动情况: db2 list active databases
若没有活动则备份db2 backup database sample
具体操作见文档16——定时备份的文档。
6.恢复数据库
db2 restore database sample
7. 更改 db2 日志空间的大小

备注:以下命令为了防止 db2 数据库过份使用硬盘空间而设,仅用于开发者自己机器上的 db2 ,如果是服务器,则参数需要修改。

db2 UPDATE DB CFG FOR USING logretain OFF logprimary 3 logsecond 2 logfilsiz 25600;

如果页大小是 4KB ,则以上命令创建 3 个 100M 的日志文件,占用 300MB 硬盘空间。 25600*4KB=102400KB 。

8.Database Administration Server (DAS)

它是一个后台进程,用来远程进行图形化管理。

在Linux、Unix中,需要建立一个DAS用户,DB2ADMINSERVER变量存有这个用户的值。

命令如下:

db2admin start Starts the DAS.
db2admin stop Stops the DAS.
dascrt Creates the DAS in Linux and UNIX.
dasdrop Drops the DAS in Linux and UNIX.
db2admin create Creates the DAS in Windows.
db2admin drop Drops the DAS in Windows.
get admin cfg Displays the DAS admin configuration file.
update admin cfg Updates the DAS admin configuration file.
reset admin cfg Resets the DAS admin configuration file to its default values.

9.使用DB2Governor进行记录

使用命令db2govd可以记录几乎所有的行为和事件,这是高级管理命令,暂时不进行介绍~

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/


               作者:gnuhpc
               出处:http://www.cnblogs.com/gnuhpc/
               除非另有声明,本网站采用知识共享“署名 2.5 中国大陆”许可协议授权。


分享到:

原文地址:https://www.cnblogs.com/gnuhpc/p/2807409.html