db2新建數據庫

1、建表空間和數據庫node

1.在db2ad、db2db和db2ap上均執行:sql

[sql] view plaincopyprint?數據庫

  1. db2set db2comm=tcpip  
  2. db2set db2codepage=1386  

db2set db2comm=tcpiptcp

db2set db2codepage=1386ide

2.新建數據庫:spa

[sql] view plaincopyprint?.net

  1. db2 create db <dbname> using codeset gbk territory CN collate using identity  

db2 create db <dbname> using codeset gbk territory CN collate using identitycode

3.鏈接上數據庫:blog

[sql] view plaincopyprint?ip

  1. db2 "connect to  <dbname>"  

db2 "connect to  <dbname>"

4.建立緩衝池 + 創建表空間;
1).刪除舊的表空間:

[sql] view plaincopyprint?

  1. db2 drop tablespace  tablespace1, tablespace2, tablespace3  

db2 drop tablespace  tablespace1, tablespace2, tablespace3

2).新建緩衝池:

[sql] view plaincopyprint?

  1. db2 create bufferpool bp32k all nodes size -1 pagesize 32k  

db2 create bufferpool bp32k all nodes size -1 pagesize 32k

bp32k爲該緩衝池的名稱;
32K爲頁大小;
size=-1表示使用缺省的buffpage,而buffpage能夠經過db2 get db cfg|grep -i buff參數查看到;
3).新建表空間:

[sql] view plaincopyprint?

  1. db2 "create regular tablespace  tablespace1 pagesize 32k managed by database using(file '/usr/yixiayizi/tablespace1' 5g) bufferpool bp32k"  
  2. db2 "create regular tablespace  tablespace2 pagesize 32k managed by database using(file '/usr/yixiayizi/tablespace2' 10g) bufferpool bp32k"  
  3. db2 "create regular tablespace  tablespace3 pagesize 32k managed by database using(file '/usr/yixiayizi/tablespace3' 2g) bufferpool bp32k"  

db2 "create regular tablespace  tablespace1 pagesize 32k managed by database using(file '/usr/yixiayizi/tablespace1' 5g) bufferpool bp32k"

db2 "create regular tablespace  tablespace2 pagesize 32k managed by database using(file '/usr/yixiayizi/tablespace2' 10g) bufferpool bp32k"

db2 "create regular tablespace  tablespace3 pagesize 32k managed by database using(file '/usr/yixiayizi/tablespace3' 2g) bufferpool bp32k"

注意(file '/usr/yixiayizi/tablespace1' 5g)的設置: 第一個參數:  當指向外置盤時,file改成device;  當指向文件路徑時,爲file; 第二個參數:須要是絕對路徑; 第三個參數:該表空間的大小;

相關文章
相關標籤/搜索