DB2备份还原中常用的sql语句

初始化环境

0.启动  db2start

1.Cmd  环境下输入  db2cmd   新打开db2 操作窗口

2.连接数据库   db2 connect to  db_name

3.在本地主机备份语句   db2 backup database db_name to D:

               备份成功得到备份映像的时间戳 

 

4.在该环境下创建数据库    db2 create database db_name

Db2  create database pb_db using codeset gbk territory zh_CN pagesize 8192 ---建库;

Db2  connect to pb_db ---连接;

Db2 create bufferpool testpool size 2000 pagesize 32k --临时表空间缓冲池;

 

Db2 create temporary tablespace temp(tablespace_name) pagesize 32k managed by database using (file '数据库所在路径\文件所在路径.file' 5000) extentsize 80 bufferpool testpool --临时表空间;

------查看数据库的表空间

Db2  list  tablespaces show  detail 

 

 

           命令成功完成

5. 连接数据库

        Db2 connect to db_name 

6.  db2  restore database  old_name  from  d:\(只写到备份文件所在的根目录)  taken at  201722  into  new_name

       报错 sql2542n--未备份表空间,需要重定向表空间备份

posted @ 2017-09-04 16:45  办公室的仙人掌  阅读(647)  评论(0编辑  收藏  举报